Make conins
global of type int. Let coin label is coinLabel
. Make 3 bool
global variable such as btn1Pressed,btn2Pressed,btn3Pressed
. In viewDidLoad
make as btn1Pressed = btn2Pressed = btn3Pressed =false;
. Then do something like this:
-(IBAction)btnHint:(id)sender {
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.5];
CGPoint center = [hints center];
center.x = 160;
center.y = 230;
[hints setCenter:center];
[UIView commitAnimations];
hintView.text = @"founded in 1996, and is a sub of telecome";
}
- (IBAction)firstHintq:(id)sender {
hintView.text = @"founded in 1996, and is a sub of telecome";
if(!btn1Pressed) {
if((coins -10) >= 0){
coins = coins -10;
btn1Pressed = true
coinLabel.text = [NSString stringWithFormat:@"%d",coins];
}
else{
//Show an alert that the user has not enough coins
}
}
}
- (IBAction)secondHintq:(id)sender {
[_candletwo setImage:[UIImage imageNamed:@"candle2_03.png"] forState:UIControlStateNormal];
hintView.text = @"Type in text here 2";
if(!btn2Pressed) {
if((coins -10) >= 0){
coins = coins -10;
btn2Pressed = true
coinLabel.text = [NSString stringWithFormat:@"%d",coins];
}
else{
//Show an alert that the user has not enough coins
}
}
}
- (IBAction)thirdHintq:(id)sender {
hintView.text = @"Type in the third hint here";
[_candlethree setImage:[UIImage imageNamed:@"candle2_03.png"] forState:UIControlStateNormal];
if(!btn3Pressed) {
if((coins -10) >= 0){
coins = coins -10;
btn3Pressed = true
coinLabel.text = [NSString stringWithFormat:@"%d",coins];
}
else{
//Show an alert that the user has not enough coins
}
}
}
Hope this helps .. :)