zoukankan      html  css  js  c++  java
  • 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();
    }
  • 相关阅读:
    怎么看到数据库以前做过的日志?
    感觉很好的网站
    uview 滑动切换
    Flyweight享元(结构型模式)
    悟空,真的是空?
    Interpreter解释器(行为型模式)
    Proxy代理(结构型模式)
    [转]有一种爱叫索取
    Command命令(行为型模式)
    Composite组合(结构型模式)
  • 原文地址:https://www.cnblogs.com/newlist/p/3170368.html
Copyright © 2011-2022 走看看