Add assets and code template of camera fx tests.

This commit is contained in:
Sean
2013-07-13 08:43:08 +08:00
parent 6d21d39b19
commit 945c9c1a0d
8 changed files with 129 additions and 0 deletions
Binary file not shown.

After

Width:  |  Height:  |  Size: 198 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.3 KiB

+35
View File
@@ -0,0 +1,35 @@
/// <reference path="../../Phaser/Game.ts" />
(function () {
var game = new Phaser.Game(this, 'game', 800, 600, init, create, update, render);
var circle1, circle2, circle3;
var fx;
function init() {
game.world.setSize(800, 600, true);
game.load.image('blue', 'assets/tests/blue-circle.png');
game.load.image('yellow', 'assets/tests/yellow-circle.png');
game.load.image('magenta', 'assets/tests/magenta-circle.png');
game.load.start();
}
function create() {
circle1 = game.add.sprite(114, 34, 'blue');
circle2 = game.add.sprite(426, 86, 'yellow');
circle3 = game.add.sprite(221, 318, 'magenta');
circle1.input.start(0, false, true);
fx = game.camera.fx.add(Phaser.FX.Camera.Shake);
}
function update() {
if (circle1.input.justReleased(0, 20)) {
console.log('pressed');
fx.start(0.05, 0.5, function() {
console.log('fin');
});
}
}
function render() {
}
})();
+47
View File
@@ -0,0 +1,47 @@
/// <reference path="../../Phaser/Game.ts" />
(function () {
var game = new Phaser.Game(this, 'game', 800, 600, init, create, update, render);
var radar;
var ships = [];
var button;
function init() {
game.world.setSize(800, 600, true);
game.load.image('radar-surface', 'assets/tests/radar-surface.png');
game.load.image('ship', 'assets/sprites/asteroids_ship_white.png');
game.load.image('enemy-ship', 'assets/sprites/asteroids_ship.png');
game.load.image('button', 'assets/tests/320x200.png');
game.load.start();
}
function create() {
for (var i = 0; i < 4; i++) {
ships.push(game.add.sprite(100 + i * 10, 300 + i * 16, 'ship'));
}
ships.push(game.add.sprite(160, 320, 'enemy-ship'));
radar = game.add.sprite(0, 0, 'radar-surface');
game.camera.setSize(400, 600);
var camera2 = game.add.camera(0, 0, 400, 600);
camera2.x = 400;
button = game.add.sprite(500, 100, 'button');
button.input.start(0, false, true);
}
function update() {
if (button.input.justReleased(0, 20)) {
}
for (var i = 0; i < ships.length; i++) {
ships[i].x += 1;
if (ships[i].x > 400) {
ships[i].x = 40;
}
}
}
function render() {
}
})();
+47
View File
@@ -0,0 +1,47 @@
/// <reference path="../../Phaser/Game.ts" />
(function () {
var game = new Phaser.Game(this, 'game', 800, 600, init, create, update, render);
var circle1, circle2, circle3;
var button;
function init() {
game.world.setSize(800, 600, true);
game.load.image('blue', 'assets/tests/blue-circle.png');
game.load.image('yellow', 'assets/tests/yellow-circle.png');
game.load.image('magenta', 'assets/tests/magenta-circle.png');
game.load.image('button', 'assets/tests/320x200.png');
game.load.start();
}
function create() {
circle1 = game.add.sprite(114, 34, 'blue');
circle2 = game.add.sprite(426, 86, 'yellow');
circle3 = game.add.sprite(221, 318, 'magenta');
circle1.input.start(0, false, true);
circle1.input.enableDrag(false);
circle2.input.start(0, false, true);
circle2.input.enableDrag(false);
circle3.input.start(0, false, true);
circle3.input.enableDrag(false);
button = game.add.sprite(500, 100, 'button');
button.input.start(0, false, true);
}
function update() {
if (button.input.justReleased(0, 20)) {
console.log('<1>: (' + circle1.x + ', ' + circle1.y + ')');
console.log('<2>: (' + circle2.x + ', ' + circle2.y + ')');
console.log('<3>: (' + circle3.x + ', ' + circle3.y + ')');
}
}
function render() {
circle1.input.renderDebugInfo(32, 32);
circle2.input.renderDebugInfo(32, 160);
circle3.input.renderDebugInfo(32, 296);
}
})();