2012年6月13日 星期三

starling-extension-particle-system

starling with 粒子系統(火焰/燃燒/煙霧/雪花效果)

first edit the particle
幸好有線上版的..XD
http://onebyonedesign.com/flash/particleeditor/
save it

//載入粒子設定檔(剛剛存下來的兩個檔案)
var psConfig:XML = XML(new FireConfig());
var psTexture:Texture = Texture.fromBitmap(new FireParticle());

// create particle system
var ps:PDParticleSystem = new PDParticleSystem(psConfig, psTexture);
addChild(ps);

//add it to a juggler (or call its advanceTime method once per frame) to animate it.
Starling.juggler.add(ps);
ps.start();

如果要 following touch(mouse) position,監聽 touch 事件,
記得開啟 simulateMultitouch
starling.simulateMultitouch = true;

stage.addEventListener(TouchEvent.TOUCH, onTouch);
function onTouch(event:TouchEvent):void
{
  var touch:Touch = event.getTouch(stage);
  if (touch && touch.phase != TouchPhase.HOVER)
  {
    // following mouse/touch position
    ps.emitterX = touch.globalX;
    ps.emitterY = touch.globalY;
  }
}

[update:20120930]
fire effect for starling



[ref]
http://wiki.starling-framework.org/extensions/particlesystem
http://blog.onebyonedesign.com/flash/particle-editor-for-starling-framework/

沒有留言:

張貼留言