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);
答案 0 :(得分:1)
您正在寻找粒子动画,并且您正在尝试使用代码中的帧动画..如果您想使用从particle2dx.com生成的.plist文件,那么您可以这样做
首先在网站http://particle2dx.com/ - &gt;转到导出链接 - &gt;点击下载按钮写成“png contains”..现在你将下载plist文件,现在使用此代码应用粒子动画< / p>
ParticleSystemQuad *particle_Tap=ParticleSystemQuad::create("run.plist");
particle_Tap->setPosition(point);
particle_Tap->setScale(FACTOR_XY);
this->addChild(particle_Tap,100);
希望这会有所帮助.. :)