Hi,
I want to access a variable from 1 layer to another.
I tried implementing few things but all failed.
I used CC_SYNTHESIZE(int, _mNumber, mNumber);
It gave bad access in other layer when I called
@ int score = ((Samplecocos2dx *)this~~>getParent~~>getChildByTag)>getMNumber;
@
2. I used a method to return the score. It also gave bad access
3. I set tag for the layer itself. this->getParent()->addChild(GameOverLayer::node(), 2, mNumber);
When I tried to get int score = this->getTag();
Its returning1.
Hi Nikhil,
I use a class for all “global” objects, methods, etc.
In this post you will find and “example” (ejem…) well doesn’t pretend to be an example, but you could find an explanation there: http://www.cocos2d-x.org/boards/6/topics/12840
‘File.h’ and ‘File.cpp’ should act as this global class, accessed by anyother through ‘File::foo’ after include it.