cocos2d-x

How to get absolute positions of touches and layer objects?

假如想象 提交于 2020-01-16 12:18:06
问题 I'm having a weird issue with cocos2d-x when trying to detect which character (currently a CCLayer-extending object) I'm touching. The problem is that the location of the sprite I'm clicking on never matches the touch location that is registered. I've tried different conversion functions but neither of them seem to work. Any idea about how can I detect in ccTouchesBegan where a map (CCLayer) is being touched in the same 'scale' than the characters (also CCLayer's)? How can I get the absolute

接入SDK

人盡茶涼 提交于 2020-01-16 10:51:17
管理提醒: 本帖被 fm2010 设置为精华(2014-11-12) http://www.cocoachina.com/bbs/read.php?tid-239087.html 本帖属于 CocoaChina 会员发表,转帖请写明来源和帖子地址 一、Cocos2d-x环境的搭建 关于Cocos2d-x的环境搭建,网上相关的教程已经有很多了,在此就简单的介绍一下。 1.1 所需工具及软件 1、 JDK (1.7版本) 2、Android SDK(直接在Eclipse里下载所需要的SDK版本) 3、 Android NDK (r9d及以上) 4、 Ant 5、 Python (2.7版本) 6、 Eclipse ADT 7、VS2012(Windows)或XCode(Mac OS) 8、 Cocos2d-x-3.3alpha0 (本项目所使用的版本) 1.2 配置环境 准备好如上软件后,配置好JDK与Python的环境变量,执行Cocos2d-x下的setup.py进行各个环境变量的设置,然后就可以使用cocos命令了。 例子: 创建工程:cocos new demo -p com.game.demo -l cpp -d d:\cocos 编译Android:cocos compile -p android -j 4 二、AnySDK环境的搭建 下载 打包客户端及Framework

Cocos2d-js: effect on cocos2d-js application running on browser while a move from one application to another application

时光毁灭记忆、已成空白 提交于 2020-01-16 03:24:25
问题 i was running parkour game given on cocos2d website on my browser. everything was working fine, but when i move from my browser to sublime text and returned to my browser, the running player start to show some unexpected behaviour, the player disappeared from its position and and after few second it fall on the ground and then start running again .whenever i move from one application to another it happens. i don't why its happening. could some one tell me how to prevent this from happen? here

How do I turn on RTTI with Cygwin?

柔情痞子 提交于 2020-01-14 12:37:27
问题 When my Android NDK C++ native code is compiled, the following error appears: error: 'dynamic_cast' not permitted with -fno-rtti Someone told me to turn on RTTI, but I didn't know how to do. Do I need to modify Application.mk or what? my Application.mk : # it is needed for ndk-r5 APP_STL := stlport_static APP_ABI := armeabi armeabi-v7a APP_MODULES := cocos2d cocosdenshion chipmunk box2d tempestkeep When I add APP_CPPFLAGS += -frtti in some .o file appears another error: undefined reference to

rewrite the code cocos2d (objective-c) on cocos2d-x (c++)

早过忘川 提交于 2020-01-14 06:55:09
问题 Now rewrite the code from cocos2d (objective-c) to cocos2d-x (c + +) and collided with a problem: I have two classes, two CCLayer. In one class there CCMenu by pressing the button calls the second class: CCMenuItem * button = [CCMenuItemImage itemWithNormalImage: @ "1.png" selectedImage: nil block: ^ (id sender) { HelloWorldLayer * helloWorldLayer = (HelloWorldLayer *) [self.parent getChildByTag: 777]; [helloWorldLayer createSprite: self]; }]; And in the second grade, I assign Layer tag: self

Not able to change the background of the scene in cocos2dx android

牧云@^-^@ 提交于 2020-01-14 06:23:20
问题 I have started Game Development using cocos2dx. And started with HelloWorld sample game. I am able to run this sample game. But when I try to change the Background Color, I am getting error in **HelloWorldScene.h** The type 'HelloWorld' must implement the inherited pure virtual method 'cocos2d::CCRGBAProtocol::setOpacity' **Changes:** class HelloWorld : public cocos2d::CCLayerColor and also in **HelloWorldScene.cpp** Invalid arguments ' Candidates are: bool initWithColor(const cocos2d::

Cocos2D-x - Issues when with using CCFollow

左心房为你撑大大i 提交于 2020-01-13 06:58:08
问题 I've got a problem with CCFollow in Cocos2D-X. I want to follow my a Sprite, which is referred to a Box2D-Body. When i call this->runAction(CCFollow::create(playerSprite)); in the init method of my GameLayer, the lower left corner of my usual screen is centered on my device and although the emulator. May anyone help me with this issue ? :/ Best Regards, stotheg 回答1: ССFollow is often not enough for your own purposes. One way out of this situation is to create your custom ССFollow action or

Touches priority in cocos2d/cocos2d-x

自作多情 提交于 2020-01-12 05:50:09
问题 I am trying to play around with touches in cocos2d-x . I have question on the priority of the touches for example , When I use CCMenuItemSprite or CCControlButton which are added on the Layer which has setTouchEnabled(true) or even If I put a What I found is touch is not first given to ccTouchesBegan (...I mean Layer) instead it is taken by CCMenuItemSprite or CCCOntrolButton call backs . Moreover , If I add an extra layer top on all the layers and setTouchEnable (True) same results I get

音频/音效/视频播放(利用Cocos2D-iPhone-Extensions嵌入Cocos2d进行视频播放!)

坚强是说给别人听的谎言 提交于 2020-01-11 13:58:14
原文链接: http://www.himigame.com/iphone-cocos2d/482.html 今天Himi为大家讲解如何在cocos2d中视频、音乐、音效的播放教程; 首先介绍音乐、音效的播放: 音频与音效的播放很简单,毕竟cocos2d引擎为我们封装好了这一切,直接上代码: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 //----------------音乐相关 //加载音乐 +( void )loadBgMusic{ // [[SimpleAudioEngine sharedEngine] preloadBackgroundMusic:@"himi.caf"]; } //播放背景音乐 +( void )playBgMusic:(NSString*)fileName{ [[SimpleAudioEngine sharedEngine] playBackgroundMusic:fileName]; } //暂停背景音乐 +( void )pauseBgMusic{ [[SimpleAudioEngine sharedEngine] pauseBackgroundMusic]; } //继续播放背景音乐 +( void )resumeBgMusic{ [

Set NDK_MODULE_PATH for cocos2dx Android

时光毁灭记忆、已成空白 提交于 2020-01-11 06:45:11
问题 I am very new to cocos2dx for android.Now i install cygwin and all enviroment variables . Now when i compile and bulid my project (sample project) it gives message and error that NDK_MODULE_PATH not found . Here is my LOGCAT: 14:26:15 **** Incremental Build of configuration Default for project HelloCpp **** bash C:/Workspace/HelloCpp/build_native.sh NDK_DEBUG=1 V=1 NDK_ROOT = C:\android-ndk-r9b COCOS2DX_ROOT = /cygdrive/c/Workspace/HelloCpp/../../../.. APP_ROOT = /cygdrive/c/Workspace