mirror of
https://github.com/wassname/phaser.git
synced 2026-07-10 00:30:50 +08:00
Added Phaser.Graphics and fixed the Out of World Bounds call.
This commit is contained in:
@@ -12,7 +12,7 @@
|
||||
|
||||
(function () {
|
||||
|
||||
var game = new Phaser.Game(800, 600, Phaser.CANVAS, '', { preload: preload, create: create, update: update, render: render });
|
||||
var game = new Phaser.Game(800, 600, Phaser.AUTO, '', { preload: preload, create: create, update: update, render: render });
|
||||
|
||||
function preload() {
|
||||
game.load.image('alien', 'assets/sprites/space-baddie.png');
|
||||
@@ -33,10 +33,10 @@
|
||||
{
|
||||
for (var x = 0; x < 10; x++)
|
||||
{
|
||||
var alien = aliens.create(x * 48, y * 50, 'alien');
|
||||
var alien = aliens.create(200 + x * 48, y * 50, 'alien');
|
||||
alien.name = 'alien' + x.toString() + y.toString();
|
||||
alien.events.onOutOfBounds.add(alienOut, this);
|
||||
alien.body.velocity.y = 50 + Math.random() * 150;
|
||||
alien.body.velocity.y = 50 + Math.random() * 200;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,7 +44,10 @@
|
||||
|
||||
function alienOut(alien) {
|
||||
|
||||
// Move the alien to the top of the screen again
|
||||
alien.reset(alien.x, -32);
|
||||
// And give it a new random velocity
|
||||
alien.body.velocity.y = 50 + Math.random() * 200;
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user