<1>
#ifndef __Eliminate__Animationsprite__#define __Eliminate__Animationsprite__#include <stdio.h>#include "cocos2d.h"#include "cocostudio/CocoStudio.h"USING_NS_CC;using namespace std;using namespace cocostudio;//----------///普通的动物//----------typedef enum { disPLAY_MODE_norMAL = 0,//正常 disPLAY_MODE_HORIZONTAL,//消除所在列的精灵 disPLAY_MODE_VERTICAL,//消除所在行的精灵 disPLAY_MODE_TL,//t、l型 disPLAY_MODE_OVERFIVE,//五个以上消除 disPLAY_MODE_CENTER,//十字型 disPLAY_MODE_FF,//向外扩散一个格 disPLAY_MODE_HHH,//三列 disPLAY_MODE_VVV,//三行 disPLAY_MODE_CRYSTAL //结晶 --jn新增} displayMode;class Animationsprite:public Armature{public: Animationsprite(int row,int col,int imgIndex); static Animationsprite *create(const std::string& name,int row,int imgIndex); voID playAnimation(string name); CC_SYNTHESIZE(int,m_row,Row); //列 CC_SYNTHESIZE(int,m_col,Col); //行 CC_SYNTHESIZE(int,m_imgIndex,imgIndex); //标记索引 CC_SYNTHESIZE(int,m_score,score); CC_SYNTHESIZE(bool,m_isNeedRemove,IsNeedRemove); //是否需要移除 CC_SYNTHESIZE(bool,m_ignoreCheck,IgnoreCheck); CC_SYNTHESIZE(bool,m_istouchEable,IstouchEable); CC_SYNTHESIZE(bool,m_isspecial,Isspecial); //标记是否是通过特殊元素交换形成的特殊元素 //CC_SYNTHESIZE(displayMode,m_displayMode,displayMode); CC_PROPERTY(displayMode,displayMode); //--jn新增 CC_SYNTHESIZE(bool,m_isNeedtoplayEffect,IsNeedtoplayEffect); voID setoverFiveimg();private: Armature* _armatureHeng; //横消动画 Armature* _armatureShu; //竖消动画};#endif /* defined(__Eliminate__Animationsprite__) */
#include "Animationsprite.h"#include "DataConfig.h"#include "BasicInclude.h"Animationsprite::Animationsprite(int row,int imgIndex){ ArmatureDataManager::getInstance()->addArmaturefileInfo("Animals/xiongmao_Animation0.png","Animals/xiongmao_Animation0.pList","Animals/xiongmao_Animation.ExportJson"); ArmatureDataManager::getInstance()->addArmaturefileInfo("Animals/tuzi_Animation0.png","Animals/tuzi_Animation0.pList","Animals/tuzi_Animation.ExportJson"); ArmatureDataManager::getInstance()->addArmaturefileInfo("Animals/qingwa_Animation0.png","Animals/qingwa_Animation0.pList","Animals/qingwa_Animation.ExportJson"); ArmatureDataManager::getInstance()->addArmaturefileInfo("Animals/qIE_Animation0.png","Animals/qIE_Animation0.pList","Animals/qIE_Animation.ExportJson"); ArmatureDataManager::getInstance()->addArmaturefileInfo("Animals/laohu_Animation0.png","Animals/laohu_Animation0.pList","Animals/laohu_Animation.ExportJson"); ArmatureDataManager::getInstance()->addArmaturefileInfo("Animals/huliAnimation0.png","Animals/huliAnimation0.pList","Animals/huliAnimation.ExportJson"); ArmatureDataManager::getInstance()->addArmaturefileInfo("Animals/zusNewAnimation0.png","Animals/zusNewAnimation0.pList","Animals/zusNewAnimation.ExportJson"); this->m_row = row; this->m_col = col; this->m_imgIndex = imgIndex; this->m_score = 5; this->m_isNeedRemove = false; this->m_ignoreCheck = false; this->m_istouchEable = false; this->m_isspecial = false; this->m_displayMode = disPLAY_MODE_norMAL; _armatureHeng = NulL; _armatureShu = NulL; m_isNeedtoplayEffect = true;}Animationsprite *Animationsprite::create(const std::string& name,int imgIndex){ Animationsprite *armature = new Animationsprite(row,col,imgIndex); if (armature && armature->init(name)) { armature->autorelease(); return armature; } CC_SAFE_DELETE(armature); return nullptr;}voID Animationsprite::playAnimation(string name){ if(this->getAnimation()){ this->getAnimation()->play(name); }else{ log("<<<animation 不可为空!!! Animationsprite::playAnimation"); }}voID Animationsprite::setdisplayMode(displayMode var){ m_displayMode = var; ArmatureDataManager::getInstance()->addArmaturefileInfo("SpecialEffect/teshudaoju_NewAnimation0.png","SpecialEffect/teshudaoju_NewAnimation0.pList","SpecialEffect/teshudaoju_NewAnimation.ExportJson"); if(m_displayMode != disPLAY_MODE_norMAL){ playAudio(siwuxiaoEffect); } if(m_displayMode == disPLAY_MODE_HORIZONTAL){ if(!_armatureShu){ _armatureShu = Armature::create("teshudaoju_NewAnimation"); _armatureShu->getAnimation()->play("zongxiang"); this->addChild(_armatureShu,100); log("Anchorpoint,x: %f,y:%f",_armatureShu->getAnchorPoint().x,_armatureShu->getAnchorPoint().y); } }else if (m_displayMode == disPLAY_MODE_VERTICAL){ if(!_armatureHeng){ _armatureHeng = Armature::create("teshudaoju_NewAnimation"); _armatureHeng->getAnimation()->play("hengxiang"); this->addChild(_armatureHeng,101); } }else if(m_displayMode == disPLAY_MODE_TL){ //TL的特效目前还没有 if(!_armatureShu){ _armatureShu = Armature::create("teshudaoju_NewAnimation"); _armatureShu->getAnimation()->play("zongxiang"); this->addChild(_armatureShu,100); _armatureHeng = Armature::create("teshudaoju_NewAnimation"); _armatureHeng->getAnimation()->play("hengxiang"); this->addChild(_armatureHeng,101); } }else if (m_displayMode == disPLAY_MODE_OVERFIVE){// setoverFiveimg();// log("<<<fengche"); }}displayMode Animationsprite::getdisplayMode(){ return m_displayMode;}voID Animationsprite::setoverFiveimg(){// playAnimation("fengche"); //这样时不行的。。。在这添加一个动画的特效还差不多}<2>
ArmatureDataManager::getInstance()->addArmaturefileInfo("menu/startmenu/zhujIEmian_Animation0.png","menu/startmenu/zhujIEmian_Animation0.pList","menu/startmenu/zhujIEmian_Animation.ExportJson");
Armature *armatureSun = Armature::create("zhujIEmian2_Animation");armatureSun->setposition(winSize.wIDth / 2,winSize.height / 2);armatureSun->getAnimation()->playWithIndex(0);armatureSun->setScale(winScaleMin); //----jnthis->addChild(armatureSun,-1); armatureSun->getAnimation()->setMovementEventCallFunc(this,movementEvent_selector(StartScene::movementCallback));
voID StartScene::movementCallback(Armature * armature,MovementEventType type,const std::string& movementID){ if (type == COMPLETE) { if (strcmp(movementID.c_str(),"guang") == 0) { armature->getAnimation()->playWithIndex(1,1,1); } }}
Armature *armature = Armature::create("teshudaoju_NewAnimation"); //锤子爆破特效 --jn新增armature->setposition(point);armature->getAnimation()->play("chuizi");m_spLayer->addChild(armature,10);removeArmature(armature);
voID GameScene::removeArmature(Node *node){ Armature *armature = (Armature *)node; if (armature) { armature->getAnimation()->setMovementEventCallFunc(this,movementEvent_selector(GameScene::movementCallback)); }}
#pragma mark 将动画移除voID GameScene::movementCallback(Armature * armature,const std::string& movementID){ if (type == COMPLETE) { armature->removeFromParent(); }}总结
以上是内存溢出为你收集整理的利用Cocostudio动画编辑器导出资源播放动画全部内容,希望文章能够帮你解决利用Cocostudio动画编辑器导出资源播放动画所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)