cocos2d-x场景与层的使用

本文介绍了在Cocos2d-x中如何创建Setting类并实现与HelloWorld场景之间的切换。通过继承cocos2d::Layer,设置场景切换函数如pushScene()和popScene(),并应用TransitionJumpZoom过渡动画实现平滑效果。
摘要由CSDN通过智能技术生成

今天学习了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
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值