Shane K wrote:
Hi, i was wondering what the difference between the init() function and the onEnter() function was? Does one happen before the other?
If i run a scene it runs the init function but what happens when i change to another scene and then change back. Does it run the init function again? What about onEnter? Does it run again if i change scene and then change back?
Init is part of creating an object and helps initialize it
Object* obj = new Object();
if you check the documentation onEnter() happens when the scene is presented by the CCDirector. If you are an iOS developer you can think of this like viewDidAppear. Don’t forget though, if you have a subclassed CCLayer that overrides onEnter(), you should also make sure that at the beginning of the method it calls the onEnter for CCLayer, like this:
//your code goes here