cocos2d-x

cocos2d-x动画加速与减速

佐手、 提交于 2019-12-07 15:12:33
原文 http://blog.csdn.net/henren555/article/details/24244021 原作者:扬名天吓 动画是游戏的必然要素之一,在整个游戏过程中,又有着加速、减速动画的需求。以塔防为例子,布塔的时候希望能够将游戏减速,布好塔后,则希 望能将游戏加速;当某个怪被冰冻后,移动速度减缓,而其他怪的移动速度不变。cocos2d-x引擎为我们提供了很强大的接口,下面就将我实验的过程复述 一遍,也方便他人。 1)实现全局的加速、减速。 通过设置Scheduler的timeScale,可以实现全局的加、减速。代码非常简单: CCScheduler* pScheduler = CCDirector::sharedDirector()->getScheduler(); pScheduler->setTimeScale(2.0f); //实现加速效果 pScheduler->setTimeScale(0.5f);//实现减速效果 2)实现对某个CCActionInterval动作的加速、减速 方法一:很容易想到的一个方法就是改变CCAnimation的delay unit。代码如下: CCAnimation* pAnimation = CCAnimationCache::sharedAnimationCache()->animationByName(“xxx”);

Cocos2d-x动画加速与减速

落花浮王杯 提交于 2019-12-07 15:12:19
动画是游戏的必然要素之一,在整个游戏过程中,又有着加速、减速动画的需求。以塔防为例子,布塔的时候希望能够将游戏减速,布好塔后,则希望能将游戏加速;当某个怪被冰冻后,移动速度减缓,而其他怪的移动速度不变。cocos2d-x引擎为我们提供了很强大的接口 1)实现全局的加速、减速。 通过设置Scheduler的timeScale,可以实现全局的加、减速。代码非常简单: CCScheduler* pScheduler = CCDirector::sharedDirector()->getScheduler(); pScheduler->setTimeScale(2.0f); //实现加速效果 pScheduler->setTimeScale(0.5f);//实现减速效果 2)实现对某个CCActionInterval动作的加速、减速 方法一:很容易想到的一个方法就是改变CCAnimation的delay unit。代码如下: AnimationCache* cache = CCAnimationCache::sharedAnimationCache(); CCAnimation* pAnimation = cache->animationByName(“xxx”); pAnimation->setDelayUnit(pAnimation->getDelayUnit()*0.2f); /

Cocos2D-x HelloCpp for Android unable to build apk from Windows due to permission denied on asset file

青春壹個敷衍的年華 提交于 2019-12-07 07:28:57
问题 I was trying to run cocos2dx HelloCpp sample project on Android, building from Windows-7 64 bit with Cygwin 64 bit, however, everytime I try to build and run, it complains that permission was denied on "Marker Felt.fnt" file in assets/font folder. I checked that there's no permission on that file and chmod to give it proper permission, but everytime I try to run again, that file seems to be regenerated and has no permission again... Does anyone has the same problem? I have been googling and

proper instantiation & memory management in cocos2d-x

ぃ、小莉子 提交于 2019-12-07 07:02:56
问题 I've been looking for documentation for cocos2d-x but it seems to be really really poor beyond the very basics. I understand that my own classes should inherit from CCObject to be able to use (originally cocoa's) retain / release mechanism, but I'm still confused about what happens when you new something. init is not called automatically. is it OK to call it from inside the constructor? does that alone guarantee that my object will start with a reference count of 1? what is CC_SAFE_DELETE and

Recolor sprites on the fly

帅比萌擦擦* 提交于 2019-12-07 06:12:18
问题 I need to replace colors of the sprite. Some example founded in google Here is I've found a looks like working solution for Unity - [How to Use a Shader to Dynamically Swap a Sprite's Colors][2] How to port it to cocos2d-x? Can someone please help with code examples? I'm looking for cocos2d-x v3 code snippet. Really looking forward for some help. 回答1: The algorithm in the article How to Use a Shader to Dynamically Swap a Sprite's Colors is very simple. It is based on a one dimensional lookup

Cocos2D-x sample application crashes on launch

删除回忆录丶 提交于 2019-12-07 03:50:27
I tried to build the Cocos2D-x testCpp sample project (Cocos2D-x 2.2.2) on my Android device using the command line interface as described in the Readme.md file: $ cd cocos2d-x/samples/Cpp/TestCpp/proj.android/ $ export NDK_ROOT=/path/to/ndk $ ./build_native.sh $ ant debug install If the last command results in sdk.dir missing error then do: $ android list target $ android update project -p . -t (id from step 6) $ android update project -p cocos2d-x/cocos2dx/platform/android/java/ -t (id from step 6) I can install the app on my device (Galaxy S4) but the application crashes immediately after

Cocos2d-x如何控制动作速度

ぃ、小莉子 提交于 2019-12-07 01:11:48
基本动作和组合动作实现了针对精灵的各种运动和动画效果的改变。但这样的改变速度匀速的、线性的。通过ActionEase及其的派生类和Speed 类我们可以使精灵以非匀速或非线性速度运动,这样看起了效果更加逼真。 ActionEase的类图如下图所示。 下面我们通过一个实例介绍一下这些动作中速度的控制的使用,这个实例如下图所示,上图是一个操作菜单场景,选择菜单可以进入到下图动作场景,在下图动作场景中点击Go按钮可以执行我们选择的动作效果,点击Back按钮可以返回到菜单场景。 下面我们再看看具体的程序代码,首先看一下看HelloWorldScene.h文件,它的代码如下: [html] view plain copy #ifndef __HELLOWORLD_SCENE_H__ #define __HELLOWORLD_SCENE_H__ #include "cocos2d.h" #include "MyActionScene.h" typedef enum ① { kEaseIn = 1 ,kEaseOut ,kEaseInOut ,kEaseSineIn ,kEaseSineOut ,kEaseSineInOut ,kEaseExponentialIn ,kEaseExponentialOut ,kEaseExponentialInOut ,kSpeed } ActionTypes;

Cocos2d-JS中的文本菜单

心已入冬 提交于 2019-12-07 01:11:18
文本菜单是菜单项只能显示文本,文本菜单类包括了cc.MenuItemLabel、cc.MenuItemFont和cc.MenuItemAtlasFont。cc.MenuItemLabel是个抽象类,具体使用的时候是使用cc.MenuItemFont和cc.MenuItemAtlasFont两个类。 文本菜单类cc.MenuItemFont,它的其中一个构造函数定义如下: [html] view plain copy ctor(value, //要显示的文本 callback, //菜单操作的回调函数指针 target) 文本菜单类cc.MenuItemAtlasFont是基于图片集的文本菜单项,它的其中一个构造函数定义如下: [html] view plain copy ctor (value, //要显示的文本 charMapFile, //图片集文件 itemWidth, //要截取的文字在图片中的宽度 itemHeight, //要截取的文字在图片中的高度 startCharMap //开始字符 callback ) //菜单操作的回调函数指针 本节我们会通过一个实例介绍一下文本菜单的使用,这个实例如图4-12所示,其中菜单Start是使用cc.MenuItemFont实现的,菜单Help是使用cc.MenuItemAtlasFont实现的。 文本菜单实例 下面我们看看app

cocos2d-x CCTouchDispatcher - no sharedDispatcher

瘦欲@ 提交于 2019-12-06 21:11:46
问题 I'm currently porting an ObjC cocos2d game to cocos2d-x, but I'm encountering some problems when trying to create a registerWithTouchDispatcher method, at the moment I'm doing void GameLayer::registerWithTouchDispatcher() { CCTouchDispatcher::sharedDispatcher()->addTargetedDelegate(this,0,true); } but this gives an error 'No member named sharedDispatcher' in cocos2d::CCTouchDispatcher'. Is there another way that this must be done in cocos2d-x? 回答1: If you are using 2.0, they have been merged

how to setup cocos2d-x on windows 7..need a n00bs guide !!? [closed]

时光总嘲笑我的痴心妄想 提交于 2019-12-06 16:26:04
问题 It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 6 years ago . well i am on windows 7 ,64 bit,having the ADT bundle for windows.. i am a bit confused with all the tutorials(a) cocos2d-x setup for android on windows 7,also they are too old..after that the cocos2d-x has been