mirror of
https://github.com/photonstorm/phaser
synced 2024-12-24 20:13:35 +00:00
26 lines
711 B
JavaScript
26 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);
|
|
}
|
|
|
|
}
|