cocos2d-x

Compiling OpenSSL on Android

萝らか妹 提交于 2019-11-29 17:38:54
I'm currently trying to get my Cocos2D-X project to connect to my server through SSL and I got it to work on iOS without a lot of issues, however on Android I'm not able to even get OpenSSL to compile.. I've searched on Google quite a lot but all posts either keep re-directing me to HTTPS related posts (which this is not, I'm not using HTTP in any way shape or form here, purely OpenSSL), posts on how to do it with the standard Android SDK in Java or posts which just aren't helpful at all. Can someone please show me how I can compile the Android version of this game and get it to connect to my

Undefined symbols in Crypto++/iOS 64-bit project

拥有回忆 提交于 2019-11-29 16:27:59
I tried to build with github's prebuilt cryptopp but it doesn't work, too. it occur errors like below: Undefined symbols for architecture arm64: "CryptoPP::BufferedTransformation::ChannelFlush(std::string const&, bool, int, bool)", referenced from: vtable for CryptoPP::SimpleProxyFilter in MYCLASSBBB.o vtable for CryptoPP::Bufferless<CryptoPP::Filter> in MYCLASSBBB.o "CryptoPP::Filter::CopyRangeTo2(CryptoPP::BufferedTransformation&, unsigned long long&, unsigned long long, std::string const&, bool) const", referenced from: vtable for CryptoPP::Base64Decoder in MYCLASSBBB.o vtable for CryptoPP:

Cocos2dx - Unable to set velocity = 0.0

无人久伴 提交于 2019-11-29 16:22:26
I'm making an pool game with cocos2dx. First, i setup the edgeBox with this parameters PhysicsMaterial(1.0f, 1.0f, 0.8f) And then these 2 balls PhysicsMaterial(1.0f, 1.0f, 0.5f) On the update function, i want slow down balls time by time without gravity (like making ground friction) by adding physicsBody->setLinearDamping(0.3); On the update function, i set the minimum velocity, if the velocity of each ball reaches lower than 15, reset velocity to 0,0 auto MV = 15; auto v1 = player1->getPhysicsBody()->getVelocity(); auto v2 = player2->getPhysicsBody()->getVelocity(); if (v1.x > MV || v1.x <

Getting and setting the RGB / RGBA value of a pixel in a CCSprite (cocos2d-x)

∥☆過路亽.° 提交于 2019-11-29 14:41:18
问题 Why do I need this? Basically I need to turn a color image into gray-scale. Including a gray-scale version of the image could be a solution, but space is tight in my situation - I don't want my APK to be too big. Besides, I would like to work on the pixels for some effects too. Again, this is to make the APK smaller. I have found getPixel setPixel from CCTexture2D and Getting image's pixel RGBA, but I would like something more simple. Any help is appreciated. Thank you! 回答1: Here is my

Cocos2d-x在win平台下显示字体边缘有锯齿的解决

[亡魂溺海] 提交于 2019-11-29 10:44:15
6/27号新进展: 大范围的重新改写,安全和性能上有更高的提高,但因涉及修改的文档比较多,有兴趣要的可以联系我本人索要。 近几天在玩弄ccx的时候发现在win下的字体显示有严重的锯齿问题,拜读了下win平台下的字体解决方案,结果让我有些失望。ccx是采用win32 api将font画到DC上然后 GetDIBits取出位图数据经过处理放到位图数组中,锯齿问题是因为它简化了边缘alpha的处理。注释原文是: change pixel's alpha value to 255, when it's RGB != 0 很明显这样处理是错误的,应该根据当前像素的灰度来决定alpha值的大小。 另外一个让我比较失望的地方是在读取ttf文件时必须将文件名改为ttf文件的fontname,因为它默认是取文件名为fontname,如果文件名和ttf文件的字体名称不一致的话是无法使用ttf的字模的。这里我稍微修改了一下,目前能够解析ttf的文件头读取文件名。本身我是打算用freetype库来代替ccx在win下的字体解决方案(之前我自己开发的FScript就是采用freetype取代dx自身的id3dxfont),但是目前还不需要改得那么复杂,以后有需要的时候再加上吧。 解决前: 解决后的效果: /***************************************************

Cocos2d-JS事件处理机制

穿精又带淫゛_ 提交于 2019-11-29 10:19:08
在很多图形用户技术中,事件处理机制一般都有三个重要的角色:事件、事件源和事件处理者。事件源是事件发生的场所,通常就是各个视图或控件,事件处理者是接收事件并对其进行处理的一段程序。 事件处理机制中三个角色 在Cocos2d-JS引擎事件处理机制中也有这三个角色。 1、事件 事件类是cc.Event,它的类图如下图所示,它的子类有:cc.EventTouch(触摸事件)、cc.EventMouse(鼠标事件)、cc.EventCustom(自定义)、cc.EventKeyboard(键盘事件)和cc.EventAcceleration(加速度事件)。 事件类图 2、事件源 事件源是Cocos2d-JS中的精灵、层 、菜单等节点对象。 3、事件处理者 Cocos2d-JS中的事件处理者是事件监听器类cc.EventListener ,它包括几种不同类型的监听器: cc.EventListener.ACCELERATION。加速度事件监听器。 cc.EventListener.CUSTOM。自定义事件监听器。 cc.EventListener.KEYBOARD。键盘事件监听器。 cc.EventListener.MOUSE。鼠标事件监听器。 cc.EventListener.TOUCH_ALL_AT_ONCE。多点触摸事件监听器。 cc.EventListener.TOUCH_ONE_BY

搭建Cocos2d-JS开发环境

我们两清 提交于 2019-11-29 10:18:58
使用Cocos2d-JS引擎开发游戏,主要的程序代码是JavaScript语言,因此,凡是能够开发JavaScript语言工具都适用于Cocos2d-JS游戏开发。本书我们推荐WebStorm和Cocos Code IDE工具。 搭建WebStorm开发环境 我们在以往使用了WebStorm开发工具,它是非常优秀的JavaScript开发工具,WebStorm工具可以开发和调试基于Cocos2d-JS引擎的JavaScript程序代码,但是测试和调试时候只能运行在Web浏览器上。 WebStorm安装过程我们已经介绍了,但是要想开发基于Cocos2d-JS引擎的JavaScript程序,我们还需要安装Google Chrome浏览器和JetBrains IDE Support插件,Google Chrome浏览器安装我们不再介绍,我们重点介绍JetBrains IDE Support插件, JetBrains IDE Support是安装在Google Chrome浏览器上的插件,它是为了配合WebStorm工具调试使用的。JetBrains IDE Support插件安装过程是在Google Chrome浏览器的网址中输入https://chrome.google.com/webstore/detail/jetbrains-ide-support

Cocos2d-JS中JavaScript继承

纵然是瞬间 提交于 2019-11-29 10:18:46
JavaScript语言本身没有提供类,没有其它语言的类继承机制,它的继承是通过对象的原型实现的,但这不能满足Cocos2d-JS引擎的要求。由于Cocos2d-JS引擎是从Cocos2d-x演变而来的,在Cocos2d-JS的早期版本Cocos2d-HTML中几乎全部的API都是模拟Cocos2d-x API而设计的,Cocos2d-x本身是有C++编写的,其中的很多对象和函数比较复杂,JavaScript语言描述起来有些力不从心了。 在开源社区中John Resiq在他的博客(http://ejohn.org/blog/simple-javascript-inheritance/)中提供了一种简单JavaScript继承(Simple JavaScript Inheritance)方法。 John Resiq的简单JavaScript继承方法灵感来源于原型继承机制,它具有与Java等面向对象一样的类概念,并且他设计了所有类的根类Class,它的代码如下: [html] view plain copy /* Simple JavaScript Inheritance * By John Resig http://ejohn.org/ * MIT Licensed. */ // Inspired by base2 and Prototype (function(){ var

JavaScript语言标识符和保留字

一曲冷凌霜 提交于 2019-11-29 10:18:31
任何一种计算机语言都离不开标识符和保留字,下面我们将详细介绍JavaScript标识符和关键字。 标识符 标识符就是给变量、函数和对象等指定的名字。构成标识符的字母是有一定的规范,JavaScript语言中标识符的命名规则: 区分大小写,Myname与myname是两个不同的标识符。 标识符首字符可以是以下划线(_)、美元符($)或者字母开始,不能是数字。 标识符中其它字符可以是下划线(_)、美元符($)、字母或数字组成的。 例如,identifier,userName,User_Name,_sys_val,身高,$change等为合法的标识符,而2mail,room#,class为非法的标识符。其中,使用中文“身高”命名的变量是合法的。 注意 JavaScript中的字母是采用Unicode,Unicode叫做统一编码制,是国际上通用的16位编码制,它包含了亚洲文字编码,如中文、日文、韩文等字符。所有JavaScript中的字母可以是中文、日文和韩文等亚洲字母。 保留字 保留字是语言中定义具有特殊含义的标识符,保留字不能作为标识符使用。JavaScript语言中定义了一些具有专门的意义和用途的保留字,这些保留字称为关键字,下面列出了JavaScript语言中的关键字: break、delete、function、return、typeof、case、do、if、switch

Cocos2d-JS键盘事件

三世轮回 提交于 2019-11-29 10:17:34
Cocos2d-JS中的键盘事件与触摸事件不同,它没有空间方面信息。键盘事件不仅可以响应键盘,还可以响应设备的菜单。 键盘事件是EventKeyboard,对应的键盘事件监听器(cc.EventListener.KEYBOARD),键盘事件响应属性: onKeyPressed。当键按下时回调该属性所指定函数。 onKeyReleased。当键抬起时回调该属性所指定函数。 使用键盘事件处理的代码片段如下: [html] view plain copy onEnter: function () { this._super(); cc.log("HelloWorld onEnter"); cc.eventManager.addListener({ ① event: cc.EventListener.KEYBOARD, ② onKeyPressed: function(keyCode, event){ ③ cc.log("Key with keycode " + keyCode + " pressed"); }, onKeyReleased: function(keyCode, event){ ④ cc.log("Key with keycode " + keyCode + " released"); } }, this); }, onExit: function () { this.