Recommended Posts

Hi,

 

I'm trying to get an explosion working with animated particles in Phaser. So far I've got the emitted working fine and seem to be able to add animations to the particles, but running these animations does nothing.

 

Since the docs say that "Particles are extended Sprites" I would assume that you can add and run animations in the same way that you do an a normal sprite?

 

Any help would be greatly appreciated!!

var game = new Phaser.Game(800, 600, Phaser.AUTO, 'phaser-example', { preload: preload, create: create });var emitter;function preload() {    game.load.spritesheet('partAnim', 'assets/partAnim.png', 134, 141);}function create() {    game.physics.startSystem(Phaser.Physics.ARCADE);    game.stage.backgroundColor = 0x337799;    emitter = game.add.emitter(0, 0, 100);    emitter.makeParticles('partAnim');    emitter.gravity = 200;    game.input.onDown.add(particleBurst, this);}function particleBurst(pointer) {    emitter.x = pointer.x;    emitter.y = pointer.y;    emitter.start(true, 2000, null, 1);    var part = emitter.getTop();    part.animations.add('run');    part.animations.play('run', 15, true);    console.log(part);}

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.