cocos2dx 3.2helloWord 分析

废话不说:直接看代码注释

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


//USING_NS_CC == using namespace cocos2d
USING_NS_CC;//using namespace cocos2d






//构造函数
AppDelegate::AppDelegate() {


}
//析构函数
AppDelegate::~AppDelegate() 
{
}


//程序初始化函数
bool AppDelegate::applicationDidFinishLaunching() {
    // initialize director
//获取设备
    auto director = Director::getInstance();
//取得OpenGL窗口
    auto glview = director->getOpenGLView();
    if(!glview) {
//如果为空,则创建以" www.sundaboke.com"为窗口标题的窗口。  
        glview = GLView::create("www.sundaboke.com");//这里我修改过 //刚刚开始是My Game 我修改成www.sundaboke.com  cocos2dx 默认的设置的窗口大小是960,640
//设置设备使用的窗口,此句可以去掉。  
//director->setOpenGLView(glview);这一句我个人医保写在下面
    }
//设置设备使用的窗口,
director->setOpenGLView(glview);



    // turn on display FPS
//打开FPS显示
    director->setDisplayStats(true);


    // set FPS. the default value is 1.0/60 if you don't call this
//设置每秒60帧
    director->setAnimationInterval(1.0 / 60);


    // create a scene. it's an autorelease object
//创建HelloWorld场景
    auto scene = HelloWorld::createScene();


    // run
//运行场景
    director->runWithScene(scene);


    return true;
}


// This function will be called when the app is inactive. When comes a phone call,it's be invoked too
//当收到电话时,游戏转入后台服务,响应这句话
void AppDelegate::applicationDidEnterBackground() {
    Director::getInstance()->stopAnimation();


//如果使用使用,下面可以用这句代码暂停
    // if you use SimpleAudioEngine, it must be pause
    // SimpleAudioEngine::getInstance()->pauseBackgroundMusic();
}


// this function will be called when the app is active again
//当电话完成,选择恢复游戏是,响应这一句
void AppDelegate::applicationWillEnterForeground() {
    Director::getInstance()->startAnimation();


    // if you use SimpleAudioEngine, it must resume here
//如果使用声音,下面可以用这句代码恢复
    // SimpleAudioEngine::getInstance()->resumeBackgroundMusic();
}


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值