mirror of
https://github.com/wassname/phaser.git
synced 2026-09-09 11:28:47 +08:00
Fixed lots of examples and added the missing Line.js.
This commit is contained in:
@@ -25,8 +25,8 @@ var s;
|
||||
|
||||
function create() {
|
||||
|
||||
// We do this so the ball can still rebound with the world bounds, but it will look like it has gone off the bottom of the screen
|
||||
game.world.height = 620;
|
||||
// This tells the world to include walls on the left, right and top, but not the bottom - so the ball can 'fall' away.
|
||||
game.physics.setBoundsToWorld(true, true, true, false);
|
||||
|
||||
s = game.add.tileSprite(0, 0, 800, 600, 'starfield');
|
||||
|
||||
@@ -54,6 +54,7 @@ function create() {
|
||||
ball.body.collideWorldBounds = true;
|
||||
ball.body.bounce.setTo(1, 1);
|
||||
ball.animations.add('spin', [ 'ball_1.png', 'ball_2.png', 'ball_3.png', 'ball_4.png', 'ball_5.png' ], 50, true, false);
|
||||
ball.events.onOutOfBounds.add(ballLost, this);
|
||||
|
||||
scoreText = game.add.text(32, 550, 'score: 0', { font: "20px Arial", fill: "#ffffff", align: "left" });
|
||||
livesText = game.add.text(680, 550, 'lives: 3', { font: "20px Arial", fill: "#ffffff", align: "left" });
|
||||
@@ -90,12 +91,6 @@ function update () {
|
||||
game.physics.collide(ball, bricks, ballHitBrick, null, this);
|
||||
}
|
||||
|
||||
// Out?
|
||||
if (ball.y > 600 && ballOnPaddle == false)
|
||||
{
|
||||
ballLost();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function releaseBall () {
|
||||
@@ -115,7 +110,7 @@ function ballLost () {
|
||||
|
||||
lives--;
|
||||
|
||||
if (lives == 0)
|
||||
if (lives === 0)
|
||||
{
|
||||
gameOver();
|
||||
}
|
||||
@@ -123,9 +118,9 @@ function ballLost () {
|
||||
{
|
||||
livesText.content = 'lives: ' + lives;
|
||||
ballOnPaddle = true;
|
||||
ball.body.velocity.setTo(0, 0);
|
||||
ball.x = paddle.x + 16;
|
||||
ball.y = paddle.y - 16;
|
||||
ball.body.reset();
|
||||
ball.animations.stop();
|
||||
}
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ var lives;
|
||||
var enemyBullet;
|
||||
var firingTimer = 0;
|
||||
var stateText;
|
||||
var livingEnemies=[];
|
||||
var livingEnemies = [];
|
||||
|
||||
function create() {
|
||||
|
||||
@@ -106,10 +106,10 @@ function createAliens () {
|
||||
aliens.y = 50;
|
||||
|
||||
// All this does is basically start the invaders moving. Notice we're moving the Group they belong to, rather than the invaders directly.
|
||||
var tween = game.add.tween(aliens).to( { x: 200 }, 2000, Phaser.Easing.Linear.None, true, 0, 1000, true);
|
||||
// var tween = game.add.tween(aliens).to( { x: 200 }, 2000, Phaser.Easing.Linear.None, true, 0, 1000, true);
|
||||
|
||||
// When the tween completes it calls descend, before looping again
|
||||
tween.onComplete.add(descend, this);
|
||||
// tween.onComplete.add(descend, this);
|
||||
}
|
||||
|
||||
function setupInvader (invader) {
|
||||
@@ -155,8 +155,8 @@ function update() {
|
||||
}
|
||||
|
||||
// Run collision
|
||||
game.physics.collide(bullets, aliens, collisionHandler, null, this);
|
||||
game.physics.collide(enemyBullets, player, enemyHitsPlayer, null, this);
|
||||
// game.physics.collide(bullets, aliens, collisionHandler, null, this);
|
||||
// game.physics.collide(enemyBullets, player, enemyHitsPlayer, null, this);
|
||||
|
||||
}
|
||||
|
||||
@@ -167,8 +167,8 @@ function collisionHandler (bullet, alien) {
|
||||
alien.kill();
|
||||
|
||||
// Increase the score
|
||||
score+=20;
|
||||
scoreText.content=scoreString+score;
|
||||
score += 20;
|
||||
scoreText.content = scoreString + score;
|
||||
|
||||
// And create an explosion :)
|
||||
var explosion = explosions.getFirstDead();
|
||||
|
||||
Reference in New Issue
Block a user