zoukankan      html  css  js  c++  java
  • cocos2dx 的基本框架

    AppDelegate.h

    #ifndef  _APP_DELEGATE_H_
    #define  _APP_DELEGATE_H_
    
    #include "cocos2d.h"
    
    USING_NS_CC;
    
    /**
    @brief    The cocos2d Application.
    
    The reason for implement as private inheritance is to hide some interface call by CCDirector.
    */
    class  AppDelegate : private cocos2d::CCApplication
    {
    public:
        AppDelegate();
        virtual ~AppDelegate();
    
        /**
        @brief    Implement CCDirector and CCScene init code here.
        @return true    Initialize success, app continue.
        @return false   Initialize failed, app terminate.
        */
        virtual bool applicationDidFinishLaunching();
    
        /**
        @brief  The function be called when the application enter background
        @param  the pointer of the application
        */
        virtual void applicationDidEnterBackground();
    
        /**
        @brief  The function be called when the application enter foreground
        @param  the pointer of the application
        */
        virtual void applicationWillEnterForeground();
    };
    
    #endif // _APP_DELEGATE_H_
    

      

    AppDelegate.cpp

    #include "AppDelegate.h"  
    
    #include <vector> 
    #include <string>
    
    #include "PlayingScene.h"
    #include "AppMacros.h"
    
    USING_NS_CC;
    using namespace std;
    
    #define DESIGN_WIDTH	420
    #define DESIGN_HEIGHT	720
    
    AppDelegate::AppDelegate() {
    
    }
    
    AppDelegate::~AppDelegate() 
    {
    }
    
    bool AppDelegate::applicationDidFinishLaunching() {
    
    	CCDirector* pDirector = CCDirector::sharedDirector();
    	CCEGLView* pEGLView = CCEGLView::sharedOpenGLView();	
    
    	pDirector->setOpenGLView(pEGLView);
    	pEGLView->setDesignResolutionSize(DESIGN_WIDTH, DESIGN_HEIGHT, kResolutionShowAll);
    
    	pDirector->setAnimationInterval(1.0 / 60);
    	CCScene *pScene = PlayingScene::scene();
    	pDirector->runWithScene(pScene);
    
    	return true;
    }
    
    void AppDelegate::applicationDidEnterBackground() {
    	CCDirector::sharedDirector()->stopAnimation();
    }
    
    void AppDelegate::applicationWillEnterForeground() {
    	CCDirector::sharedDirector()->startAnimation();
    }

    main.cpp
    #include "main.h"
    #include "../Classes/AppDelegate.h"
    #include "CCEGLView.h"
    
    USING_NS_CC;
    
    int APIENTRY _tWinMain(HINSTANCE hInstance,
                           HINSTANCE hPrevInstance,
                           LPTSTR    lpCmdLine,
                           int       nCmdShow)
    {
    	UNREFERENCED_PARAMETER(hPrevInstance);
    	UNREFERENCED_PARAMETER(lpCmdLine);
    
        // create the application instance
        AppDelegate app;
        CCEGLView* eglView = CCEGLView::sharedOpenGLView();
        eglView->setViewName("HelloCpp");
    	//eglView->setFrameSize(384,640);
    	eglView->setFrameSize(240,400);
    	eglView->setFrameZoomFactor(1.0f);
        return CCApplication::sharedApplication()->run();
    }
    

      

      

  • 相关阅读:
    Jsoup爬取带登录验证码的网站
    HDFS的java客户端编写
    【Eclipse】Elipse自定义library库并导入项目
    一个爬取https和http通用的工具类(JDK自带的URL的用法)
    爬取网站图片保存到本地
    java在CMD窗口执行程序的时候输入密码(隐藏一些敏感信息)
    htmlunit爬虫工具使用--模拟浏览器发送请求,获取JS动态生成的页面内容
    利用Jsoup模拟跳过登录爬虫获取数据
    jsoup抓取网页报错UnsupportedMimeTypeException
    Java爬虫(二)
  • 原文地址:https://www.cnblogs.com/colife/p/3508530.html
Copyright © 2011-2022 走看看