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();
}
cocos2dx 的基本框架的更多相关文章
- 基于cocos2d-x的游戏框架设计——李成
视频:http://v.youku.com/v_show/id_XMzc5ODUyMTI4.html?f=17330006 网易科技讯 3月31日,第四届CocoaChina开发者大会暨Cocos2d ...
- Cocos2d-x之引擎框架简介
| 版权声明:本文为博主原创文章,未经博主允许不得转载. 1.cocos2d-x的设计思想 cocos2d-x分为导演,场景,图层,精灵,节点: (1).导演(Director):控制整个游戏的场 ...
- [原创]cocos2d-x研习录-第二阶 基本框架
了解完Cocos2D-x的基本概念和概念类之后,是不是有一种蠢蠢欲动的冲动,想要探究Cocos2D-x是如何完成这一切的.接着我将通过对Cocos2D-x自代的HelloCpp项目进行分析,初步了解C ...
- Cocos2d-x学习笔记(两)Cocos2d-x总体框架
原创文章.转载请注明出处:http://blog.csdn.net/sfh366958228/article/details/38680123 前言 上一节我们简单分析了HelloWorldproje ...
- cocos2dx游戏开发——微信打飞机学习笔记(一)——开发准备
一.环境的搭建 1.Windows开发准备: (1)软件下载及安装 •下载Cocos2d-x 最新版本:http://www.cocos2d-x.org/download 或者从Cocos2d-x G ...
- [原创]cocos2d-x研习录-第二阶 概念类之节点类(CCNode)
节点类CCNode在基本概念中并不存在,它是为了建立基本概念之间的关联关系而抽象出来的中间辅助类.这个类在Cocos2D-x中极为重要,它为概念类之间搭建了一座宏伟的桥梁.它的继承关系图如下: ...
- [原创]cocos2d-x研习录-第二阶 基本概念
在Cocos2D-x引擎中,有几个非常重要的概念:导演(CCDirector).摄像机(CCCamera).场景(CCSecen).布景(CCLayer).精灵(CCSPrite)和动作(CCActi ...
- 初识cocos2d-x-从环境配置到整体框架
前言 ACM生涯在带着些许遗憾中结束了.春招的时候找了一份游戏开发的工作,现在学习cocos2dx中. 从ACM竞赛到实际项目开发的学习,第一感觉就是不适应,虽然感觉实际项目的确要比ACM简单的多.最 ...
- win7 vs2010 安装cocos2d-x
http://blog.csdn.net/leoncoder/article/details/12523727 新安装搭建cocos2d-X的跳过这里,看以下红色開始: cocos2d-x删除vs20 ...
随机推荐
- Eclipse下jad反编译之“类文件查看器”不能处理给定的输入错误解决
Eclipse中的插件下载,安装和配置可以参考我的另一篇文章:MyEclipse反编译Class文件 下面重点讲解如何使用jad反编译 1.在DOS窗口中,到class所在目录,直接运行 >ja ...
- 关于IOS中的delegate必须知道的事情
当你开始写iOS程式不久,应该开始面对到很多的delegate, 不管是用别人的library或是自己写library,可能都逃不了delegate. 为了怕有些人不知道什么是delegate,在这边 ...
- Hashmap in java
1. HashMap要点: 1.1 基本数据结构: 采用 数组+链表/平衡二叉查找树 的组合形式,所有键值对都以Entry<K,V>形式存储(每put进一个键值对,就会实例化一个Entr ...
- vagrant在windows下的使用
vagrant在windows下的使用 下载安装 VirtualBox :https://www.virtualbox.org/ 下载安装 Vagrant :http://www.vagrantup. ...
- C#错误:The Controls collection cannot be modified
用 <%# %>这种写法是写在数据绑定控件中的,之所以用 <%= %>会出现The Controls collection cannot be modified because ...
- Scrum10-22
Time:2013-10-22 Author:居玉皓 Things we have done since yesterday's meeting: 在今天的Scrum中,STORY1 开发前期准备工作 ...
- .Net webservice动态调用
直接贴代码吧 public class PmsService { /// <summary> /// pms接口 /// </summary> /// <param na ...
- ruby 格式化当前日期时间
ruby 格式化当前日期时间 ruby 用Time类获取当前时间. t = Time.new puts t 可以看到输出的是(我现在运行的时间): Sat Jan 29 10:45:22 +0800 ...
- Nginx正确记录post日志的方法
Nginx正确记录post日志的方法 事实上可以很简单,这取决于把 access_log 放在哪个 location 里面. 一,放到包含fastcgi_pass或proxy_pass的Locatio ...
- c# 4.0新特性一览
原文:http://www.cnblogs.com/palo/archive/2009/03/01/1400949.html 终于静下心来仔细听了一遍Anders Hejlsberg(Visual S ...