This commit is contained in:
Webeled
2013-10-07 20:56:44 +01:00
parent 664c512a99
commit 77b553ac2a
23 changed files with 47 additions and 96 deletions
+1 -1
View File
@@ -27,7 +27,7 @@
function create() {
//We increase the size of our game world
game.world.setSize(2000, 2000);
game.world.setBounds(2000, 2000);
for (var i = 0; i < 1000; i++)
{
+9 -17
View File
@@ -15,7 +15,7 @@
var speed=4;
function preload() {
game.world.setSize(1280, 600);
game.world.setBounds(1280, 600);
game.load.image('ground', 'assets/tests/ground-2x.png');
game.load.image('river', 'assets/tests/river-2x.png');
game.load.image('sky', 'assets/tests/sky-2x.png');
@@ -31,18 +31,12 @@
}
function create() {
// background images
game.add.sprite(0, 0, 'sky')
.scrollFactor.setTo(0, 0);
game.add.sprite(0, 360, 'ground')
.scrollFactor.setTo(0.5, 0.5);
game.add.sprite(0, 400, 'river')
.scrollFactor.setTo(1.3, 1.3);
game.add.sprite(200, 120, 'cloud0')
.scrollFactor.setTo(0.3, 0.3);
game.add.sprite(-60, 120, 'cloud1')
.scrollFactor.setTo(0.5, 0.3);
game.add.sprite(900, 170, 'cloud2')
.scrollFactor.setTo(0.7, 0.3);
game.add.sprite(0, 0, 'sky');
game.add.sprite(0, 360, 'ground');
game.add.sprite(0, 400, 'river');
game.add.sprite(200, 120, 'cloud0');
game.add.sprite(-60, 120, 'cloud1');
game.add.sprite(900, 170, 'cloud2');
// Create a ufo sprite as player.
ufo = game.add.sprite(320, 240, 'ufo');
@@ -53,11 +47,9 @@
// Add 2 sprite to display hold direction.
leftBtn = game.add.sprite(160 - 112, 200, 'button', 0);
leftBtn.scrollFactor.setTo(0, 0);
leftBtn.alpha = 0;
rightBtn = game.add.sprite(640 - 112, 200, 'button', 1);
rightBtn.alpha = 0;
rightBtn.scrollFactor.setTo(0, 0);
}
function update() {
// Check key states every frame.
@@ -65,13 +57,13 @@
if (game.input.keyboard.isDown(Phaser.Keyboard.LEFT) &&
!game.input.keyboard.isDown(Phaser.Keyboard.RIGHT)) {
ufo.x -= speed;
ufo.rotation = -15;
ufo.angle = -15;
leftBtn.alpha = 0.6;
}
else if (game.input.keyboard.isDown(Phaser.Keyboard.RIGHT) &&
!game.input.keyboard.isDown(Phaser.Keyboard.LEFT)) {
ufo.x += speed;
ufo.rotation = 15;
ufo.angle = 15;
rightBtn.alpha = 0.6;
}
else {
@@ -15,7 +15,7 @@
var speed=4;
function preload() {
game.world.setSize(1280, 600);
game.world.setBounds(1280, 600);
game.load.image('ground', 'assets/tests/ground-2x.png');
game.load.image('river', 'assets/tests/river-2x.png');
game.load.image('sky', 'assets/tests/sky-2x.png');
@@ -33,18 +33,12 @@
}
function create() {
// background images
game.add.sprite(0, 0, 'sky')
.scrollFactor.setTo(0, 0);
game.add.sprite(0, 360, 'ground')
.scrollFactor.setTo(0.5, 0.5);
game.add.sprite(0, 400, 'river')
.scrollFactor.setTo(1.3, 1.3);
game.add.sprite(200, 120, 'cloud0')
.scrollFactor.setTo(0.3, 0.3);
game.add.sprite(-60, 120, 'cloud1')
.scrollFactor.setTo(0.5, 0.3);
game.add.sprite(900, 170, 'cloud2')
.scrollFactor.setTo(0.7, 0.3);
game.add.sprite(0, 0, 'sky');
game.add.sprite(0, 360, 'ground');
game.add.sprite(0, 400, 'river');
game.add.sprite(200, 120, 'cloud0');
game.add.sprite(-60, 120, 'cloud1');
game.add.sprite(900, 170, 'cloud2');
// Create a ufo sprite as a player.
ufo = game.add.sprite(320, 240, 'ufo');
@@ -55,15 +49,12 @@
// Add 2 sprite to display hold direction.
leftBtn = game.add.sprite(160 - 112, 200, 'button', 0);
leftBtn.scrollFactor.setTo(0, 0);
leftBtn.alpha = 0;
rightBtn = game.add.sprite(640 - 112, 200, 'button', 1);
rightBtn.alpha = 0;
rightBtn.scrollFactor.setTo(0, 0);
// Add a sprite to display spacebar press.
spaceBtn = game.add.sprite(400 - 112, 100, 'spacebar');
spaceBtn.transform.scrollFactor.setTo(0, 0);
spaceBtn.alpha = 0;
// Prevent directions and space key events bubbling up to browser,
@@ -84,13 +75,13 @@
if (game.input.keyboard.isDown(Phaser.Keyboard.LEFT) &&
!game.input.keyboard.isDown(Phaser.Keyboard.RIGHT)) {
ufo.x -= speed;
ufo.rotation = -15;
ufo.angle = -15;
leftBtn.alpha = 0.6;
}
else if (game.input.keyboard.isDown(Phaser.Keyboard.RIGHT) &&
!game.input.keyboard.isDown(Phaser.Keyboard.LEFT)) {
ufo.x += speed;
ufo.rotation = 15;
ufo.angle = 15;
rightBtn.alpha = 0.6;
}
else {
@@ -112,7 +103,7 @@
game.debug.renderText('Hold left/right to move the ufo.', 16, 32);
game.debug.renderText('Direction and Space key events are stopped by Phaser now,', 16, 48);
game.debug.renderText('so they will no longer be sent to the browser', 16, 64);
game.debug.renderText('so they will no longer be sent to the browser', 16, 64);
game.debug.renderText('Now you can press UP/DOWN or SPACE to see what happened.', 16, 80);
}
+1 -2
View File
@@ -23,11 +23,10 @@
function create() {
// Make our world big ...
game.world.setSize(4000, 2000);
game.world.setBounds(4000, 2000);
// Scrolling background
s = game.add.tileSprite(0, 0, 800, 600, 'stars');
s.scrollFactor.setTo(0, 0);
b = game.add.sprite(200, 200, 'mummy');
b.anchor.setTo(0.5, 0.5);