I know this is a very beginner question, but I’ve been struggling to figure it out.
I’m trying to build an iOS game (using cocos2d) and so I have 2 sets of files
GameScene.h and gameScene.m
MainMenu1.h and MainMenu1.m
GameScene has the sharedcode I’ve leaned to put in.
I call my MainMenu1 – the user chooses how many players from a MenuItemwithImage and that calls ChoosePlayers
I can figure out which menu item was touched, but I need to pass the number of players back to GameScene
in GameScene I put in
-(void) setPlayers (nsinteger*) players
{
totalplayers = players;
}
so in mainmenu1 chooseplayers i did
[[GameScene SharedGameData] setPlayers : 2];
but that doesn’t work.
I’m sorry, I don’t have the code in front of me (not until tonight); i’ve been searching for hours and can’t figure it out.
Your method format is incorrect. It should be:
NSInteger is not a pointer either.
To pass multiplie values, you coud either pass in an array, or:
-(void)setPlayers:(NSInteger)firstValue withSecondValue:(NSInteger)secondValue;and when you want to call it, it would look like this:[[GameScene SharedGameData] setPlayers:2 withSecondValue:4];