phaser/examples/particles/collision.js

33 lines
751 B
JavaScript
Raw Normal View History

2013-10-22 02:58:20 +00:00
var game = new Phaser.Game(800, 600, Phaser.CANVAS, 'phaser-example', { preload: preload, create: create, update: update });
var emitter;
function preload() {
game.load.spritesheet('veggies', 'assets/sprites/fruitnveg32wh37.png', 32, 32);
}
function create() {
emitter = game.add.emitter(game.world.centerX, game.world.centerY, 250);
emitter.makeParticles('veggies', [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20], 200, true, true);
emitter.minParticleSpeed.setTo(-200, -300);
emitter.maxParticleSpeed.setTo(200, -400);
emitter.gravity = 150;
2013-10-22 02:58:20 +00:00
emitter.bounce.setTo(0.5, 0.5);
emitter.angularDrag = 30;
emitter.start(false, 8000, 400);
}
function update() {
game.physics.collide(emitter);
2013-10-22 02:58:20 +00:00
}