How we can perform Action on Sequence UIButtons?
- by Prince Shazad
As My Screen shot show that i am working on word matching game.In this game i assign my words to different UIButtons in Specific sequence on different loctions(my red arrow shows this sequence)and of rest UIButtons i assign a one of random character(A-Z).when i Click on any UIButtons its title will be assign to UILabel which is in Fornt of Current Section:i campare this UILabel text to below UILabels text which is in fornt of timer.when it match to any of my UILabels its will be deleted.i implement all this process already.
But my problem is that which is show by black lines.if the player find the first word which is "DOG". he click the Two UIButtons in Sequence,but not press the Third one in Sequence.(as show by black line).so here i want that when player press the any UIButtons which is not in Sequence then remove the previous text(which is "DO") of UILabel and now the Text of UILabel is only "G" .
Here is my code to get the UIButtons titles and assign it UILabel.
- (void)aMethod:(id)sender
{
UIButton *button = (UIButton *)sender;
NSString *get = (NSString *)[[button titleLabel] text];
NSString *origText = mainlabel.text;
mainlabel.text = [origText stringByAppendingString:get];
if ([mainlabel.text length ]== 3)
{
if([mainlabel.text isEqualToString: a]){
lbl.text=@"Right";
[btn1 removeFromSuperview];
score=score+10;
lblscore.text=[NSString stringWithFormat:@"%d",score];
words=words-1;
lblwords.text=[NSString stringWithFormat:@"%d",words];
mainlabel.text=@"";
a=@"tbbb";
}
else if([mainlabel.text isEqualToString: c]){
lbl.text=@"Right";
[btn2 removeFromSuperview];
score=score+10;
lblscore.text=[NSString stringWithFormat:@"%d",score];
words=words-1;
lblwords.text=[NSString stringWithFormat:@"%d",words];
mainlabel.text=@"";
c=@"yyyy";
}
else
if([mainlabel.text isEqualToString: d]){
lbl.text=@"Right";
[btn3 removeFromSuperview];
score=score+10;
lblscore.text=[NSString stringWithFormat:@"%d",score];
words=words-1;
lblwords.text=[NSString stringWithFormat:@"%d",words];
mainlabel.text=@"";
d=@"yyyy";
}
else {
lbl.text=@"Wrong";
mainlabel.text=@"";
}
}}
Thanx in advance