anekix
anekix

Reputation: 2563

cocos2dx v3 particle animation

Hi i am new to cocos2dx v3 and i find it has very clean api but very poor documentation. i am trying to load some particle animation from http://particle2dx.com/ . from there i get a .plist file how to open it and load animation. as far as sprite sheet animation from a .plist file i know ho to do it but in that case i know the frame names and there number beforehand . but how to play particle animations from .plist file .

here is what i do to play from a .plist file how can i modify it

auto cache = SpriteFrameCache::getInstance();
cache->addSpriteFramesWithFile("run.plist");
Vector<SpriteFrame*> frames = Vector<SpriteFrame*>();


frames.pushBack(cache->getSpriteFrameByName("0001.png"));
frames.pushBack(cache->getSpriteFrameByName("0002.png"));
frames.pushBack(cache->getSpriteFrameByName("0003.png"));
frames.pushBack(cache->getSpriteFrameByName("0004.png"));
frames.pushBack(cache->getSpriteFrameByName("0005.png"));
frames.pushBack(cache->getSpriteFrameByName("0006.png"));
Animation* anim = cocos2d::Animation::createWithSpriteFrames(frames, 0.1f, 1);

Animate* anim_action = cocos2d::Animate::create(anim);
auto sprite = Sprite::create("boy1.png");
//sprite is already added to scene elsewhere and ready to go
sprite->runAction(RepeatForever::create(anim_action));
sprite->setPosition(Vec2(visibleSize.width/2 + origin.x, visibleSize.height/2 + origin.y));
this->addChild(sprite, 2);

Upvotes: 0

Views: 390

Answers (1)

bbm20891
bbm20891

Reputation: 144

you are looking for a particle animation and you are trying frame animation in your code.. if you want to use .plist file generated from particle2dx.com then you can do this

first in the website http://particle2dx.com/ ->go to export link ->click on download button written "png contained"..now you will have plist file downloaded , now use this code to apply particle animation

ParticleSystemQuad *particle_Tap=ParticleSystemQuad::create("run.plist");
particle_Tap->setPosition(point);
particle_Tap->setScale(FACTOR_XY);
this->addChild(particle_Tap,100);

Hope this helps..:)

Upvotes: 1

Related Questions