Pretty much what the title is, I want to know, how to add a button after an integer goes to a certain number.
If anyone knows how please tell me!
Thanks, Jason Chitla
Add a button after an integer goes to a certain number???
(7 posts) (2 voices)-
Posted 1 year ago #
-
if (x == threshold) { // add button }Posted 1 year ago # -
No not like that. I already made a CCMenu in the init method with this:
menu = [CCMenu menuWithItems: nil];
Because I want to add buttons to it as a certain integer object goes up to a certain number.
I dont know how to do that.Posted 1 year ago # -
if (x == threshold) { [menu addChild:newButton]; [menu draw]; }Posted 1 year ago # -
This is what I have:
if(score == 5){
CCMenuItem *blue = [CCMenuItemFont itemFromString:@"Power" target:self selector:@selector(onPower)];
kpMenu = [CCMenu menuWithItems:blue,nil];
kpMenu.position = ccp(50,50);
[self addChild:kpMenu];}
This code is in a seperate method that is in my update method.
Why wont this work?Posted 1 year ago # -
Look at my code above. It assume you created 'menu' already. All you have to do is add the new item and then draw the menu again to have it show up.
If you created kpMenu outside of the if statement you posted, that means you are trying to create the menu from scratch all over again which is not what you want to do.
Posted 1 year ago # -
O thanks it works
Posted 1 year ago #
Reply
You must log in to post.