spineRunTime for cocos2dx v3 中动画播完删除animation
spineRunTime for cocos2dx v3 中删除animation,发现下面写法会崩溃:
spine::SkeletonAnimation* animationNode = spine::SkeletonAnimation::createWithFile("explosion/explosion.json", "explosion/explosion.atlas", 1);
animationNode->setAnimation(0, "animation", false);
animationNode->setPosition(ccp(x,y));
animationNode->setEndListener( [animationNode] (int trackIndex) {
//spTrackEntry* entry = spAnimationState_getCurrent(animationNode->getState(), trackIndex);
//const char* t_animationName = (entry && entry->animation) ? entry->animation->name : 0;
//string animationName=t_animationName==0?"":t_animationName;
//CCLOG("%d end: %s", trackIndex, animationName.c_str());
animationNode->removeFromParentAndCleanup(true);
});
于是只好通过加一个延迟来避免崩溃,下面是可用的写法:
spine::SkeletonAnimation* animationNode = spine::SkeletonAnimation::createWithFile("explosion/explosion.json", "explosion/explosion.atlas", 1);
animationNode->setAnimation(0, "animation", false);
animationNode->setPosition(ccp(x,y));
animationNode->setEndListener( [animationNode] (int trackIndex) {
//spTrackEntry* entry = spAnimationState_getCurrent(animationNode->getState(), trackIndex);
//const char* t_animationName = (entry && entry->animation) ? entry->animation->name : 0;
//string animationName=t_animationName==0?"":t_animationName;
//CCLOG("%d end: %s", trackIndex, animationName.c_str());
animationNode->runAction(CCSequence::create(CCDelayTime::create(0.01),CCRemoveSelf::create(),NULL));
});
或者用completeListener,仍然需要加延迟:
animationNode->setCompleteListener( [animationNode] (int trackIndex, int loopCount) {
//spTrackEntry* entry = spAnimationState_getCurrent(animationNode->getState(), trackIndex);
//const char* t_animationName = (entry && entry->animation) ? entry->animation->name : 0;
//string animationName=t_animationName==0?"":t_animationName;
//CCLOG("%d complete: %s %d", trackIndex, animationName.c_str(),loopCount);
animationNode->runAction(CCSequence::create(CCDelayTime::create(0.01),CCRemoveSelf::create(),NULL));
});
spineRunTime for cocos2dx v3 中动画播完删除animation的更多相关文章
- spineRuntTime for cocos2dx v3,attack播完后回到idle
spineRuntTime for cocos2dx v3,attack播完后回到idle. _animationNode = spine::SkeletonAnimation::createWith ...
- css3中动画(transition)和过渡(animation)详析
css3中动画(transition)和过渡(animation)详析
- [Cocos2d-x v3.x]序列帧动画
简单介绍 Cocos2d-x中.动画的详细内容是依靠精灵显示出来的,为了显示动态图片,我们须要不停切换精灵显示的内容.通过把静态的精灵变为动画播放器从而实现动画效果. 动画由帧组成,每一帧都是一个 ...
- Cocos2d-x Lua中帧动画
帧动画就是按一定时间间隔.一定的顺序.一帧一帧地显示帧图片.我们的美工要为精灵的运动绘制每一帧图片,因此帧动画会由很多帧组成,按照一定的顺序切换这些图片就可以了. 在Cocos2d-x Lua中播放帧 ...
- Cocos2d-x v3.11 中的新内存模型
Cocso2d-x v3.11 一项重点改进就是 JSB 新内存模型.这篇文章将专门介绍这项改进所带来的新研发体验和一些技术细节. 1. 成果 在 Cocos2d-x v3.11 之前的版本中,使用 ...
- 使用cocos2d-x v3.1开发小游戏(基本框架)
小游戏的组成 欢迎界面 在游戏资源未全部加载完之前就需要载入,避免进入游戏会有一段黑屏时间. 可以用来展示游戏名称或者开发者logo. 开始菜单界面 一般用于显示游戏名称和关卡选择(或者称游戏难度选择 ...
- Cocos2d-x v3.6制作射箭游戏(二)
原文 Cocos2d-x v3.6制作射箭游戏(二) 六 24, 2015by RENSHANin COCOS2D-X 上章我们创建并加载了游戏地图,接下来的两章我们将实现如下的效果. 在开始之前,先 ...
- cocos2dx v3.x lua绑定分析
打算新项目转到cocos2dx v3上了,下载代码浏览过后发现改动真是非常大,结构性调整很多. 比如tolua绑定这一块,就几乎全翻新了. 胶水代码的生成,改成了全自动式的,通过clang来分析c++ ...
- Cocos2d-x v3.1 Hello world程序(四)
Cocos2d-x v3.1 Hello world程序(四) 在上一篇文章中我们我们已经使用Cocos-Console工具生成了工程,本机生成的目录为:"D:\CocosProject\T ...
随机推荐
- 笔记本建立wifi热点的实用详细步骤
准备工作: (1) 首先要打开开始菜单--->搜索“services.msc” 并打开(或者用win+R快捷键打开“运行”输入“service.msc”,点击确定)--->找到“WLAN ...
- IStat Menus 5.02 5.03 的注册码
1574-5977-7956-8062-0000 6015-5448-3282-4975-0000 9665-5955-6856-2071-0000 2447-9517-7939-5221-0000
- Cocos Studio is EOL'd
Cocos Studio is EOL'd Cocos Studio has been EOL'd as of April 2016. There will be no more releases o ...
- [Algorithm] Meeting hour optimization (Kanpsack problem) and Dynamic programming
For example we have array of meeting objects: const data = [ { name: }, { name: }, { name: }, { name ...
- [Javascript] Ternary Conditionals
/** Ternary Conditionals */ // //**Bad** // var isArthur = false; var weapon; if(isArthur){ weapon = ...
- oracle 给用户赋表空间
alter user fortune_test quota unlimited on data01;
- QoS的构建模块与机制
本文翻译自ITU-T的Technical Paper:<How to increase QoS/QoE of IP-based platform(s) to regionally agreed ...
- Memcache and Mongodb
转自:http://www.cnblogs.com/lovecindywang/archive/2010/05/19/1739025.html 先说说自己对Memcache和Mongodb的一些看法. ...
- B/S与C/S的差别
前一段时间已经结束了C/S的学习,開始了B/S的旅程,那么为什么我们要学习这两个,这两个有什么差别呢?这些差别你知道多少呢? B/S结构.即Browser/Server(浏览器/server)结构.是 ...
- SQL左连接右连接
假设有A,B两个表. 表A记录如下: aID aNum 1 a20050111 2 a20050112 3 a20050113 4 ...