2014-01-20 20:14:34 +00:00
|
|
|
|
2014-01-27 06:29:26 +00:00
|
|
|
var game = new Phaser.Game(800, 600, Phaser.AUTO, 'phaser-example', { preload: preload, create: create, update: update });
|
2014-01-20 20:14:34 +00:00
|
|
|
|
|
|
|
function preload() {
|
|
|
|
|
2014-01-27 06:29:26 +00:00
|
|
|
game.load.spritesheet('spinner', 'assets/sprites/bluemetal_32x32x4.png', 32, 32);
|
2014-01-20 20:14:34 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
var sprites;
|
|
|
|
|
|
|
|
function create() {
|
|
|
|
|
2014-01-27 06:29:26 +00:00
|
|
|
// Here we create a group, populate it with sprites, give them all a random velocity
|
|
|
|
// and then check the group against itself for collision
|
2014-01-20 20:14:34 +00:00
|
|
|
|
|
|
|
sprites = game.add.group();
|
|
|
|
|
2014-01-27 06:29:26 +00:00
|
|
|
for (var i = 0; i < 30; i++)
|
2014-01-20 20:14:34 +00:00
|
|
|
{
|
2014-01-27 06:29:26 +00:00
|
|
|
var s = sprites.create(game.rnd.integerInRange(100, 700), game.rnd.integerInRange(32, 200), 'spinner');
|
|
|
|
s.animations.add('spin', [0,1,2,3]);
|
|
|
|
s.play('spin', 20, true);
|
|
|
|
s.body.velocity.x = game.rnd.integerInRange(-200, 200);
|
2014-01-20 20:14:34 +00:00
|
|
|
s.body.velocity.y = game.rnd.integerInRange(-200, 200);
|
|
|
|
}
|
|
|
|
|
|
|
|
sprites.setAll('body.collideWorldBounds', true);
|
2014-01-27 06:29:26 +00:00
|
|
|
sprites.setAll('body.bounce.x', 1);
|
|
|
|
sprites.setAll('body.bounce.y', 1);
|
2014-02-05 05:54:25 +00:00
|
|
|
sprites.setAll('body.linearDamping', 0);
|
2014-01-27 06:29:26 +00:00
|
|
|
sprites.setAll('body.minBounceVelocity', 0);
|
2014-01-21 16:12:50 +00:00
|
|
|
|
2014-01-20 20:14:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function update() {
|
|
|
|
|
2014-01-21 16:12:50 +00:00
|
|
|
game.physics.collide(sprites);
|
2014-01-20 20:14:34 +00:00
|
|
|
|
|
|
|
}
|