2016-10-15 96 views
0

嗨,我是新來的cocos2dx v3,我覺得它有非常乾淨的API,但非常差的文檔。我正在嘗試從http://particle2dx.com/加載一些粒子動畫。從那裏我得到一個.plist文件如何打開它並加載動畫。就一個.plist文件中的精靈圖片動畫而言,我知道要做到這一點,但在那種情況下,我事先知道幀名稱和編號。但如何從.plist文件播放粒子動畫。cocos2dx v3粒子動畫

這裏是我做從的.plist文件播放我怎麼可以修改它

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); 

回答

1

你正在尋找一個粒子動畫和你在你的代碼試圖幀動畫..如果你想使用從particle2dx.com生成.plist文件,然後你可以做到這一點

首先在網站http://particle2dx.com/->去導出鏈接 - >點擊下載按鈕寫成「PNG載」..現在你將有plist文件下載,現在使用此代碼應用粒子動畫

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

希望這有助於.. :)