I have a upgradeShop.ccb file that is a layer and it has buttons on it (it's a shop to buy upgrades). I have a CCScrollView
in my MainScene
that I am loading my ugpradeShop.ccb. Everything works fine, except the buttons. When I click a button on the scrollview, a method is called that is supposed to subtract points from the player, and add the bonuses for the upgrade, and update the points label on MainScene
. The points label is just a CCLabelTTF
and it tells the player how many points the player has. I also have an NSLog
in the method to make sure that it is being called.
The NSLog
is working fine, so the method is being called when the button is tapped/clicked. The problem is that the label on MainScene
isn't changing. To try to diagnose this, I also attempted to hide a sprite that I have on MainScene
, when the button is clicked. It didn't work either.
This is what I have in MainScene
. This is the method called when clicking the button.
-(void)buyItem {
if (points >= 10) {
points -= 10;
label.string = [NSString stringWithFormat:@"%.2Lf", points];
NSLog([NSString stringWithFormat:@"%.2Lf", points]);
[self didLoadFromCCB];
}
}
I should also mention that the custom class of the CCNode
in the ugpradesShop.ccb layer is set to MainScene
. Heres a picture
I'm not sure what I'm doing wrong. I've been trying to solve this for over a week now, and reading up on the developer library but I honestly can't find what I am doing wrong.
I'm very new to obj-c so please explain in easy terms. Thank you so much.