Hi,
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();
pDirector->setOpenGLView(CCEGLView::sharedOpenGLView());
// turn on display FPS
pDirector->setDisplayStats(true);
// 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();
pDirector->runWithScene(pScene);
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"
USING_NS_CC;
#include "../GameObjects.h"
#include "../GameEvents.h"
class MenuScene : public CCScene
{
public:
MenuScene();
virtual ~MenuScene();
virtual void init();
void onMenuStartCallback(CCObject* pSender);
private:
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?