nsstring - math game quiz with multiple answers -
i have math quiz game , want user able touch buttons, right work if have 1 button set right answer. possible make button combination if answer 53 user can touch 5 button , 3 button.
viewcontroller.m
-(ibaction)easylevel:(id)sender {
question.hidden = no; selectlevel.hidden = yes; buttonone.hidden = yes; buttontwo.hidden = yes; buttonthree.hidden = yes; buttonfour.hidden = yes; buttonfive.hidden = yes; buttonsix.hidden = yes; buttonseven.hidden = yes; buttoneight.hidden = yes; buttonnine.hidden = yes; buttonzero.hidden = yes; right1.hidden = yes; right2.hidden = yes; right3.hidden = yes; right4.hidden = yes; right5.hidden = yes; right6.hidden = yes; right7.hidden = yes; right8.hidden = yes; right9.hidden = yes; right0.hidden = yes; wrong1.hidden = yes; wrong2.hidden = yes; wrong3.hidden = yes; wrong4.hidden = yes; wrong5.hidden = yes; wrong6.hidden = yes; wrong7.hidden = yes; wrong8.hidden = yes; wrong9.hidden = yes; wrong0.hidden = yes; int easyquestion = arc4random() % 2 ; switch (easyquestion) { case 0: question.text = [nsstring stringwithformat: @"what 4 x 2"]; right1.hidden = no; wrong3.hidden = no; wrong4.hidden = no; wrong5.hidden = no; wrong6.hidden = no; wrong7.hidden = no; wrong8.hidden = no; wrong9.hidden = no; wrong0.hidden = no; buttonone.hidden = no; buttontwo.hidden = no; buttonthree.hidden = no; buttonfour.hidden = no; buttonfive.hidden = no; buttonsix.hidden = no; buttonseven.hidden = no; buttoneight.hidden = no; buttonnine.hidden = no; buttonzero.hidden = no; buttonone.text = [nsstring stringwithformat: @"1"]; buttontwo.text = [nsstring stringwithformat: @"2"]; buttonthree.text = [nsstring stringwithformat: @"3"]; buttonfour.text = [nsstring stringwithformat: @"4"]; buttonfive.text = [nsstring stringwithformat: @"5"]; buttonsix.text = [nsstring stringwithformat: @"6"]; buttonseven.text = [nsstring stringwithformat: @"7"]; buttoneight.text = [nsstring stringwithformat: @"8"]; buttonnine.text = [nsstring stringwithformat: @"9"]; buttonzero.text = [nsstring stringwithformat: @"0"]; break; case 1: ..... default: break; }
any appreciated, :) stephanie
the trick how program know when user done entering digits pressing buttons?
one approach might make answer editable text field (uitextfield) , setting focus , setting keyboard numbers type keyboard (via uitextinputtraits
protocol uitextfield implements) user can type in numeric vales.
if don't want use ios keyboard , want own custom buttons can use own buttons , have action each button append appropriate digit answer string might display in uilabel , update press buttons. you'd want have back/delete button can erase digits , update string there also. model you'd have "ok" button or "done" button them indicate done , current string answer. button 1 takes string in answer string @ point , checks correct/incorrect.
hopefully that's enough going!
Comments
Post a Comment