mirror of
https://github.com/photonstorm/phaser
synced 2024-11-27 15:12:18 +00:00
27 lines
711 B
JavaScript
27 lines
711 B
JavaScript
|
|
||
|
var game = new Phaser.Game(800, 600, Phaser.AUTO, 'phaser-example', { preload: preload, create: create });
|
||
|
|
||
|
function preload() {
|
||
|
game.load.image('pineapple', 'assets/sprites/pineapple.png');
|
||
|
|
||
|
}
|
||
|
|
||
|
var pineapples;
|
||
|
|
||
|
function create() {
|
||
|
|
||
|
pineapples = game.add.group();
|
||
|
|
||
|
for (var i = 0; i < 10; i++)
|
||
|
{
|
||
|
var pineapple = pineapples.create(200 + i * 48,50, 'pineapple');
|
||
|
|
||
|
//This allows your sprite to collide with the world bounds like they were rigid objects
|
||
|
pineapple.body.collideWorldBounds=true;
|
||
|
pineapple.body.gravity.x = game.rnd.integerInRange(-5,5);
|
||
|
pineapple.body.gravity.y = 5 + Math.random() * 10;
|
||
|
pineapple.body.bounce.setTo(0.7,0.4);
|
||
|
}
|
||
|
|
||
|
}
|