Scope and autorelease problem

Scope and autorelease problem
0.0 0



I have created a Scene in my AppDelegate, but it is destroy when my function finish, so whats the correct method/way to create a Scene with new Cocos 2.0?

My current app delegate with problem:

bool AppDelegate::applicationDidFinishLaunching()
    // initialize director
    CCDirector *pDirector = CCDirector::sharedDirector();


    // turn on display FPS

    // set FPS. the default value is 1.0/60 if you don't call this
    pDirector->setAnimationInterval(1.0 / 60);

    // create a scene. it's an autorelease object
    CCScene *pScene = MenuScene::create();
   return true;      // after exit, the screen is black

My MenuScene class:

#ifndef MenuScene_H
#define MenuScene_H

#include "CCObject.h"
#include "CCScene.h"
#include "CCLayer.h"
#include "CCSprite.h"
#include "CCActionInterval.h"
#include "CCLabelTTF.h"
#include "CCMenu.h"


#include "../GameObjects.h"
#include "../GameEvents.h"

class MenuScene : public CCScene
    virtual ~MenuScene();
    virtual void init();
    void onMenuStartCallback(CCObject* pSender);
    CCSprite *sprite;
    CCLayerColor *backgorundLayer;
    CCMenu *menu; 

    virtual std::string getImage();
    virtual CCRect getRect();

#endif // MenuScene_H

If i exchange MenuScene::create by new MenuScene it works. What the difference of create a pointer with NEW or use CREATE as static? What happen when i use NEW?


No more!

I forgot: CREATE_FUNC(MenuScene);

But, with it, i dont need more the constructor and destructor, it is right?