cocos模板项目注释

这篇博客详细解读了Cocos2d-x游戏引擎的模板项目,包括AppDelegate.h和AppDelegate.cpp的职责,以及HelloWorldScene.h和HelloWorldScene.cpp中如何创建并展示初始场景。
摘要由CSDN通过智能技术生成

AppDelegate.h


#ifndef  _APP_DELEGATE_H_

#define  _APP_DELEGATE_H_


#include "cocos2d.h"


/**
@brief    The cocos2d Application.


Private inheritance here hides part of interface from Director.
*/
class  AppDelegate : private cocos2d::Application
{
public:
    AppDelegate();
    virtual ~AppDelegate();


    virtual void initGLContextAttrs();


    /**
    @brief    Implement Director and Scene init code here.
    @return true    Initialize success, app continue.
    @return false   Initialize failed, app terminate.
    */
//游戏启动时调用
    virtual bool applicationDidFinishLaunching();




    /**
    @brief  Called when the application moves to the background
    @param  the pointer of the application
    */
//游戏进入后台时调用
    virtual void applicationDidEnterBackground();


    /**
    @brief  Called when the application reenters the foreground
    @param  the pointer of the application
    */
//游戏进入前台时调用
    virtual void applicationWillEnterForeground();
};


#endif // _APP_DELEGATE_H_







Appdelegate.cpp


#include "AppDelegate.h"
#include "HelloWorldScene.h"


USING_NS_CC;
//相当于 using namespace cocos2d


//Size类有两个成员width和height
//可以不使用cocos2d::命名空间
static Size designResolutionSize(480, 320);
static cocos2d::Size smallResolutionSize = cocos2d::Size(480, 320);
static cocos2d::Size mediumResolutionSize = cocos2d::Size(1024, 768);
static cocos2d::Size largeResolutionSize = cocos2d::Size(2048, 1536);


AppDelegate::AppDelegate()
{
}


AppDelegate::~AppDelegate() 
{
}


// if you want a different context, modify the value of glContextAttrs
// it will affect all platforms
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值