今天学习了Cocosd-x中场景和层的使用。
本次实例有两个场景HelloWord , Setting,在HelloWord的游戏设置中可以切换到Setting场景
首先我们新建一个Setting类,继承自cocos2d::Layer类
具体代码如下:
#ifndef __HELLOWORLD_SCENE_H__
#define __HELLOWORLD_SCENE_H__
#include "cocos2d.h"
class HelloWorld : public cocos2d::Layer
{
public:
// there's no 'id' in cpp, so we recommend returning the class instance pointer
static cocos2d::Scene* createScene();
// Here's a difference. Method 'init' in cocos2d-x returns bool, instead of returning 'id' in cocos2d-iphone
virtual bool init();
// a selector callback
//void menuCloseCallback(cocos2d::Ref* pSender);
//
void menuItemStartCallBack(cocos2d::Ref *pSender);
void menuItemSettingCallBack(cocos2d::Ref *pSender);
void menuItemHelpCallBack(cocos2d::Ref *pSender);
// implement the "static create()" method manually
CREATE_FUNC(Hel