phaser icon indicating copy to clipboard operation
phaser copied to clipboard

arcade/Emitter.js appears to need update for 1.2

Open gabehollombe opened this issue 12 years ago • 2 comments

I'm seeing errors in arcade/Emitter.js about lines like particle.body.checkCollision.none = true; where the error message is "Uncaught TypeError: Cannot read property 'checkCollision' of null ".

After a quick glance at the codebase, it seems like arcade/Emitter.js might need to be updated to set the newly created Sprite's physics system. The docs in src/gameobjects/Sprite.js say:

By default Sprites won't add themselves to any physics system and their physics body will be null. To enable them for physics you need to call game.physics.enable(sprite, system) where sprite is the object and system is the Physics system you want to use to manage this body.

Is my assumption right? Since we're inside arcade/Emitter.js, should we just add a call after particle = new Phaser.Sprite(this.game, 0, 0, rndKey, rndFrame); that reads game.physics.enable(particle, Phaser.Physics.ARCADE)?

gabehollombe avatar Mar 09 '14 02:03 gabehollombe

I've updated this to use the ArcadePhysics system for now, so all the examples are working again properly. I'd rather this than try to shoe-horn it into p2 at this late stage, especially when particles needs totally revamping anyway (which is on the roadmap).

photonstorm avatar Mar 11 '14 10:03 photonstorm

Good call. I wasn't sure about if p2 is totally replacing ArcadePhysics or not.

gabehollombe avatar Mar 12 '14 01:03 gabehollombe