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 ...
随机推荐
- Oracle服务启动顺序导致ORA-12514
在window 上装了oracle11g,按照常规步骤安装完成后一切OK,如下图所示 C:\Users\Administrator>sqlplus /nolog SQL*Plus: Releas ...
- wstring to wchar_t*
If you want to convert from std::wstring to const WCHAR* (i.e. the returned pointer gives read-onl ...
- [Javascript] Funciton Expression
//This will load the code into the memory no matter //you call it or not function diffOfSquares(a,b) ...
- Eclipse中SVN修改的*星号没了,解决方法
Eclipse中SVN修改的*星号没了,解决方法 打开Preference 第一步:去掉外加的 ">" 第二步:勾选Outgoing changes 这样做之后," ...
- Linux下启动eclipse报错
A Java Runtime Environment (JRE) or Java Development Kit (JDK) must be avail Java RunTime Environm ...
- html-webpack-plugin插件 根据模板生成多页面
1.项目目录结构为: 2.webpack.config.js配置文件为: var htmlWebpackPlugin = require('html-webpack-plugin'); module. ...
- 项目重命名&复制项目&删除项目
项目重命名&复制项目&删除项目 CreateTime--2016年10月15日17:25:43 Author:Marydon 1.修改项目名或者复制的项目名 第一步: my ...
- python之函数用法staticmethod
# -*- coding: utf-8 -*- #python 27 #xiaodeng #python之函数用法staticmethod #http://www.cnblogs.com/hongfe ...
- 判断URL是否支持断点续传?
#python #xiaodeng #判断URL是否支持断点续传? import urllib2 req = urllib2.Request('http://ftp.ubuntu.com/') req ...
- Oracle的PLSQL别名中文出现乱码解决方法
乱码之乱,乱在心里.行而上,眼迷茫! 01.查询oracle服务端默认语言 select * from nls_database_parameters NLS_LANGUAGE AMERICAN ...