• CGameMainScene类


    #ifndef __GAMEMAIN_SCENE_H__
    #define __GAMEMAIN_SCENE_H__
    
    #include "cocos2d.h"
    
    #include "Box2D/Box2D.h"
    
    #include "SimpleAudioEngine.h"
    
    #include "CocoHead.h"
    #include "GameScene.h"
    
    class CCLayer;
    
    class CGameMainScene : public CGameScene
    {
    public:
        enum ResourceID
        {
            _ResourceId = 2,
        };
    
        enum MainSceneId
        {
            _IDD_MainSceneDialog = 101,
    
            _IDC_MainSceneBg = 10002,
        };
    public:
        CGameMainScene();
        virtual ~CGameMainScene();
    
    
        CREATE_SCENE(CGameMainScene);
    
        // Here's a difference. Method 'init' in cocos2d-x returns bool, instead of returning 'id' in cocos2d-iphone
        virtual bool init();  
        virtual bool initRes();
        
        // a selector callback
        void menuCloseCallback(CCObject* pSender);
        
        void menuMsgCallback(CCObject* pSender);
    
    protected:
        virtual void update(float dt);
    
        virtual void onEnter();
        virtual void onExit();
    
    private:
        CCLayer* m_pLayerBg;
        CCLayer* m_pLayerInfo;
    
    };
    
    #endif  // __HELLOWORLD_SCENE_H__
    #include "GameMainScene.h"
    #include "WidgetMgr.h"
    #include "Config.h"
    #include "GameLogic.h"
    #include "AudioMgr.h"
    #include "MenuDialog.h"
    #include "AboutDialog.h"
    #include "SectsInfomation.h"
    
    
    
    
    
    #if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
    #include "GameCenter.h"
    #endif // (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
    
    CGameMainScene::CGameMainScene()
    {
        m_pLayerBg = NULL;
        m_pLayerInfo = NULL;
    }
    
    CGameMainScene::~CGameMainScene()
    {
    
    }
    
    
    // on "init" you need to initialize your instance
    bool CGameMainScene::init()
    {
        bool bRet = false;
        do 
        {
            //////////////////////////////////////////////////////////////////////////
            // super init first
            //////////////////////////////////////////////////////////////////////////
    
            CC_BREAK_IF(! CCLayer::init());
    
            //////////////////////////////////////////////////////////////////////////
            // add your codes below...
            //////////////////////////////////////////////////////////////////////////
    
    
            m_pLayerBg = CCLayer::create();
            m_pLayerInfo = CCLayer::create();
    
            this->addChild(m_pLayerBg, 1);
            this->addChild(m_pLayerInfo, 2);
    
    
            bRet = true;
        } while (0);
    
        return bRet;
    }
    
    void CGameMainScene::update( float dt )
    {
    
    }
    
    void CGameMainScene::menuMsgCallback( CCObject* pSender )
    {
        
    
    }
    
    void CGameMainScene::onEnter()
    {
        CGameScene::onEnter();
    
        this->initRes();
    }
    
    
    bool CGameMainScene::initRes()
    {
        bool bRet = false;
    
        CCSprite* pBg = CCSprite::create(CConfig::getInstance()->getImageInfoById(10001)->strFile.c_str());
        pBg->setAnchorPoint(ccp(0, 0));
        m_pLayerBg->addChild(pBg, 0, 10001);
        
    
        CREATE_DIALOG(CMenuDialog, m_pLayerInfo, 0);
        CREATE_DIALOG(CAboutDialog, m_pLayerInfo, 0);
        //CREATE_DIALOG(CSectsInfomation, m_pLayerInfo, 0);
    
    
    
    
    
    
    
        
    #if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
        GameCenter::getInstance()->authenticateLocalUser();
    #endif //#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
        
        CGameLogic::getInstance()->readConfiguration();
    
        if (CGameLogic::getInstance()->getConfiguration()->bBackgroundMusic)
        {
            CAudioMgr::getInstance()->player("backgroundmusic_01", true);
        }
    
    
        CGameLogic::getInstance()->setLevel(_Level_xmb);
    
        bRet = true;
        return bRet;
    }
    
    void CGameMainScene::onExit()
    {
        CGameScene::onExit();
        
        this->removeFromParentAndCleanup(true);
        CWidgetMgr::getInstance()->clearAllWnd();
    
        //CWidgetMgr::destroy();
    }
  • 相关阅读:
    初探WebService
    【前端】CSS3实现弹出效果
    html转pdf、html页面保存为word文件、将页面上的table表格导出为excel
    DES64位加密解密
    xml文件数据上报——根据模型生成对应的xml文件进行上报
    数据上报-动态生成winform表单
    图片轮播 及通知公告上滚动 (无空隙滚动)
    jQuery 全选与不全选 Jquery each
    webform快速创建表单内容文件--oracle 数据库
    Ajax 通过post提交数据到一般处理程序,后台快速获取数据的方法
  • 原文地址:https://www.cnblogs.com/newlist/p/3170368.html
Copyright © 2020-2023  润新知