cocos2d-x

[转载]Building Cocos2d-x on RHEL / Fedora / CentOS Linux

≡放荡痞女 提交于 2019-12-01 12:33:02
This guide is intended to help anyone who wishes to build Cocos2d-x from source on an RPM-based Linux machine (RHEL / Fedora / CentOS). At the time these instructions were tested, Cocos2d-x v2.2.1 was used on Fedora 19. For RPM-based systems, there are some issues with the archive you get from http://www.cocos2d-x.org/download . If you look closely at the install-deps-linux.sh file, you will notice the deb-based package manager commands, like ‘dpkg-query’ and ‘apt-get’ which indicate this release was intended for Debian-based systems. There is another issue related to the dependency of Cocos2d

Cocos移植到Android的一些问题-SQLite3数据库移植问题

北慕城南 提交于 2019-12-01 11:18:53
首选我们讨论一下SQLite3数据库移植问题。我们在第14章节介绍了在Win32平台使用SQLite3数据库,我们介绍了两种配置环境的方法:一种是使用Cocos2d-x提供的SQLite3库配置,另一种是从SQLite官网下载源代码拷贝的工程中。第一种方法配置起来比较麻烦,关键是Cocos2d-x提供的SQLite3库只是Win32没有其它平台的,目录结构如下所示。 <游戏工程目录>\cocos2d\external\sqlite3 │ Android.mk │ ├─include │ sqlite3.h │ sqlite3ext.h │ └─libraries └─win32 sqlite3.dll sqlite3.lib 因此,我们只能采用第二种方法,从SQLite官网下载源代码压缩包,将其中的sqlite3.h和sqlite3.c文件拷贝到工程的Classes目录,然后打开<游戏工程目录>\proj.android\jni\Android.mk文件,修改LOCAL_SRC_FILES内容如下: LOCAL_SRC_FILES := hellocpp/main.cpp \ ../../Classes/AppDelegate.cpp \ ../../Classes/HelloWorldScene.cpp \ ../../Classes/sqlite3.c 其中sqlite3

Android Cocos2DX using C++ in Eclipse Helios

孤街醉人 提交于 2019-12-01 10:29:59
问题 I have used Eclipse Helios 3.6.1 for Java development. I wanted to start C++ development in the same IDE so I installed Autotools Support For CDT, C/C++ Development Tools, C/C++ Library API Documentation Hover Help plugins . I have included #include "cocos2d.h" in my HelloWorldScene.h file now when writing the below statement cocos2d::CCSprite * ccSprite; I am not getting auto completion bar(template proposals) on writing like coco and pressing Ctrl + Space from my keyboard. What can be the

cocos2d-x 新工程的把玩

こ雲淡風輕ζ 提交于 2019-12-01 10:15:07
创建了cocos的工程以及初步了解了工程的结构之后,可以尝试自己改改代码了 游戏窗口的设置 首先是AppDelegate,找到AppDelegate.cpp中AppDelegate::applicationDidFinishLaunching这个成员函数 函数中有几行代码涉及到游戏的一些设置 glview = GLViewImpl::createWithRect("teach", cocos2d::Rect(0, 0, designResolutionSize.width, designResolutionSize.height));//设置窗口的尺寸 director->setDisplayStats(true);//显示FPS director->setAnimationInterval(1.0f / 60);//设置每帧的间隔 glview->setDesignResolutionSize(designResolutionSize.width, designResolutionSize.height, ResolutionPolicy::NO_BORDER);//设置游戏的分辨率 以上三行代码是连在一起的,把setDisplayStats后的参数改成false,可以发现helloworld中左下角的FPS和Drawcall信息消失了 然后讲一下如何修改窗口的尺寸

windows下cocos2d-x工程结构讲解

筅森魡賤 提交于 2019-12-01 10:12:34
这是我们新建好的工程,稍微解释一下我们开发windows的cocos应用所用到的几个文件夹的作用 Classes文件夹,存放游戏代码中的类的部分,当然我们放在别的地方也可以,只要配置好依赖关系就行了 cocos2d文件夹,引擎的内核、文档、工具等 proj.win32文件夹 ,存放windows32位工程的文件夹,我们主要也是使用这个工程进行开发 Resources文件夹,存放游戏中使用的素材,图片、模型、音乐等 工程测试 打开proj.win32的sln文件,sln文件是visual studio的工程文件 使用本地windows调试器调试,漫长的编译zzzzzzz helloworld出来了 工程结构 展开工程,可以看到几个文件,抽象来说的话是HelloWorldScene类和AppDelegate类以及main.c和main.h AppDelegate类 应用委托类,至于为什么叫Delegate,这是因为main.c里其实就是把游戏的运行委托给了这个类 这个类可以认为是程序的入口,负责OpenGL的渲染系统和导演系统的初始化,还有界面的尺寸设置和适配 HelloWorldScene类 HelloWorldScene类就是我们的游戏的场景,也就是显示了Helloworld和Cocos的logo的界面,如果有想实现的简单游戏逻辑在这里实现即可 来源: https://www

Primitives and sprites Z index in Cocos2D-x 3.0 is not consistent?

自作多情 提交于 2019-12-01 10:08:35
问题 I have two layers. Each layer has a primitive drawing in it with OpenGL like this: void Layer1::drawPolygon() { glLineWidth(1); DrawPrimitives::setDrawColor4B(255,255,255,255); DrawPrimitives::setPointSize(1); // Anti-Aliased glEnable(GL_LINE_SMOOTH); // filled poly glLineWidth(1); Point filledVertices[] = { Point(10,120), Point(50,120), Point(50,170), Point(25,200), Point(10,170) }; DrawPrimitives::drawSolidPoly(filledVertices, 5, Color4F(0.5f, 0.5f, 1, 1 ) ); } When I addChild these layers

windows下cocos2d-x环境搭建

这一生的挚爱 提交于 2019-12-01 10:05:14
该教程使用的cocos2dx的版本为3.14,3之后的大概都差不多 Python环境搭建: cocos2dx在windows上新建工程需要用到python脚本,安装python-2.7.x,可以上 python 官网下载,记住安装的路径 配置环境变量:右键我的电脑然后点击属性(或者控制面板>系统和安全>系统),打开高级系统设置>环境变量,在系统变量找到Path变量,双击,新建,选择刚刚Python安装的路径,如D:\python;然后加上python路径下的Scripts的路径,如图所示 检测python是否安装成功:win键+R输入cmd打开命令提示符,输入python,如果出现 python安装成功 VS安装向导: vs2019下载地址 打开VS2019安装程序,新安装的话,根据向导,勾选 使用c++的桌面开发 使用c++的游戏开发 安装 cocos2d-x的测试以及新建工程: 上github或者 cocos2d官网 下载cocos2d-x的源码版本,解压,进入build文件夹,使用vs打开cocos2d-win32.sln,右键项目cpp-empty-test项目,设置为启动项,点击本地Windows调试器(绿箭头),编译速度比较慢,第一次要编译一些静态库有可能失败,失败了就编译第二次,编译完成后,如果出现helloworld窗口,证明所有环境搭建完毕。 新建工程教程:

How to create android cocos2dx splash screen?

坚强是说给别人听的谎言 提交于 2019-12-01 09:56:15
问题 This is my code I don't know how to create splash screen and how it will direct in my menu screen. All .h must be connected to BaseScreen and the BaseScreen will be the one connected in cocos2d layer. please help me in my codes. Do only thing that appears in my emulator is the sprite which I code in HelloWorldScreen.h SplashScreen.h ifndef __SPLASH_SCREEN_H__ define __SPLASH_SCREEN_H__ include "BaseScreen.h" include "cocos2d.h" class SplashScreen : BaseScreen { public: void update (); static

Cocos2d-x中__Dictionary容器以及实例介绍

[亡魂溺海] 提交于 2019-12-01 05:53:54
__Dictionary 类 在Cocos2d-x 2.x 时代它就是 CCDictionary 类 ,它是模仿Objective-C中的 NSDictionary 类而设计的 ,通过引用计数管理内存。 __ Dictionary继承于Ref 类 ,因此它所能容纳的是 Ref 及子类所创建的对象指针。 1 、创建 __ Dictionary对象 创建 __ Dictionary对象有很多函数,下面是总结常用的函数: static __Dictionary* create()。创建 __ Dictionary 。 static __Dictionary* createWithDictionary(__Dictionary* srcDict)。用一个已存在的 __Dictionary 来创建一个新的 __Dictionary 。 static __Dictionary* createWithContentsOfFile(const char *pFileName)。从属性列表文件创建 __ Dictionary。 2 、添加元素 向 __ Dictionary对象中添加元素都必须是“键 - 值 ”对,“键”可以是字符串(std::string)类型或整数(signed int)类型,而“值”必须是Ref和其子类的对象指针类型。下面是总结常用的函数: void setObject(Ref

Cocos2d-x中__Array容器以及实例介绍

好久不见. 提交于 2019-12-01 05:53:43
__Array类在Cocos2d-x 2.x时代它就是CCArray类。它是模仿Objective-C中的NSArray类而设计的,通过引用计数管理内存。__Array继承于Ref类,因此它所能容纳的是Ref及子类所创建的对象指针。 1、创建__Array对象 创建__Array对象有很多函数,下面是总结常用的函数: static __Array* create()。创建__Array。 static __Array* create(Ref* object, …)。使用一系列Ref创建__Array。 static __Array* createWithObject(Ref * object)。使用一个Ref创建__Array。 static __Array* createWithCapacity(unsigned int capacity)。创建__Array,并设置容量。 static __Array* createWith__Array(__Array* other__Array)。用一个已存在的__Array创建另一个__Array。 static __Array* createWithContentsOfFile(const std::string &pFileName) 。从属性列表文件创建__Array。 2、添加元素 向_