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 ...
随机推荐
- 升级Mac osx 10.10 后安装php 的mcrypt extension
昨天折腾到凌晨四点多,今天又到这个点,终于成功了,心情比较复杂,先记录一下,改日再整理,此刻头昏脑胀,只想蒙头大睡. 发的问题,还没人回复,自己找到答案了,英语比较蹩脚,凑合看.. http://st ...
- c/c++常用代码--清空目录
#pragma once #include <io.h>#include <stdio.h>#include <string>#include <direct ...
- VBS基础篇 - 动态数组
VBS中的动态数组需要使用System.Collections.ArrayList '建立动态数组 Dim Arrl : Set Arrl = CreateObject("System.Co ...
- openmeetings 视频会议系统介绍
在功能上,视频会议具有如下特点(这一部分转自:http://www.kissthink.com/archive/5150.html): 1.该方基于P2P技术,服务器压力小.流畅.用户之间可以互相获取 ...
- HTML的标签-W3School读后总结
学习前端知识有一段时间了,前两天想做个博客园的皮肤的静态页面.虽然做完了,但是有很多不如意的地方,反思一下,还是基础不够好,所以现在把html再过一遍.(这个是Xmind生成的图片)
- html+css学习笔记 5[表格、表单]
表格 -- 默认样式重置 表格标签: table 表格 thead 表格头 tbody 表格主体 tfoot 表格尾 tr 表格行 th 元素定义表头 ...
- mysql federated engine
mysql)) -> engine=federated -> connection='mysql://root@localhost:3306/t1/t';
- c++ read
#include <fstream> #include <iostream> int main(void) { ] = {}; ; std::ifstream read(&qu ...
- IntelliJ IDEA的Maven项目在修改时报java.lang.OutOfMemoryError: PermGen space异常
什么也不说了---内存溢出,遇见太多回了,下面是解决方式: 1.在项目设置中新建Maven,然后设置VM: 2. 在pom.xml添加下面2个插件,一个是jrebel的,一个是jetty的 <b ...
- 【POJ】【1067】取石子游戏
博弈论 这个是博弈游戏中的Wythoff博弈: 以下为我的代码: //POJ 1067 #include<cmath> #include<cstdio> #include< ...