Pages

Blank Scene Template for Cocos2dx

Here's the template for a blank scene class in Cocos2dx.  This one is called 'GamePlay', and is called from HelloWorldScene.


Gameplay.h:


#ifndef GamePlay_H_
#define GamePlay_H_



#include "cocos2d.h"

class GamePlay: public cocos2d::CCLayer {
public:
    
    
    virtual bool init();
    
    static cocos2d::CCScene* scene();
    
    CREATE_FUNC(GamePlay);
    
    
};


#endif

GamePlay.cpp:

#include "GamePlay.h"
#include "HelloWorldScene.h"
#include "SimpleAudioEngine.h"

using namespace cocos2d;
using namespace CocosDenshion;

CCScene* GamePlay::scene()
{
    
    CCScene *scene = CCScene::create();
    
    GamePlay*layer = GamePlay::create();
    
    scene->addChild(layer);

    return scene;
}


bool GamePlay::init()
{

    if ( !CCLayer::init() )
    {
        return false;
    }
    

    return true;

}



No comments:

Post a Comment