Updating and fixing tests

This commit is contained in:
Richard Davey
2013-08-02 18:32:26 +01:00
parent 4c9c50584e
commit 982faeedb8
88 changed files with 571 additions and 1722 deletions
-39
View File
@@ -1,39 +0,0 @@
/// <reference path="../../Phaser/Game.ts" />
(function () {
var myGame = new Phaser.Game(this, 'game', 800, 600, init, create, update);
function init() {
myGame.world.setSize(1920, 1920);
myGame.loader.addImageFile('grid', 'assets/tests/debug-grid-1920x1920.png');
myGame.loader.addImageFile('car', 'assets/sprites/car90.png');
myGame.loader.addImageFile('melon', 'assets/sprites/melon.png');
myGame.loader.load();
}
var car;
var melons;
function create() {
myGame.add.sprite(0, 0, 'grid');
melons = myGame.add.group();
for(var i = 0; i < 100; i++) {
var tempSprite = myGame.add.sprite(Math.random() * myGame.world.width, Math.random() * myGame.world.height, 'melon');
tempSprite.scrollFactor.setTo(1.2, 1.2);
melons.add(tempSprite);
}
car = myGame.add.sprite(400, 300, 'car');
myGame.camera.follow(car);
}
function update() {
car.velocity.x = 0;
car.velocity.y = 0;
car.angularVelocity = 0;
car.angularAcceleration = 0;
if(myGame.input.keyboard.isDown(Phaser.Keyboard.LEFT)) {
car.angularVelocity = -200;
} else if(myGame.input.keyboard.isDown(Phaser.Keyboard.RIGHT)) {
car.angularVelocity = 200;
}
if(myGame.input.keyboard.isDown(Phaser.Keyboard.UP)) {
var motion = myGame.motion.velocityFromAngle(car.angle, 300);
car.velocity.copyFrom(motion);
}
}
})();
-66
View File
@@ -1,66 +0,0 @@
/// <reference path="../../Phaser/Game.ts" />
(function () {
var myGame = new Phaser.Game(this, 'game', 800, 600, init, create, update);
function init() {
myGame.world.setSize(1920, 1920);
myGame.loader.addImageFile('grid', 'assets/tests/debug-grid-1920x1920.png');
myGame.loader.addImageFile('car', 'assets/sprites/car90.png');
myGame.loader.addImageFile('melon', 'assets/sprites/melon.png');
myGame.loader.load();
}
var car: Phaser.Sprite;
var melons: Phaser.Group;
function create() {
myGame.add.sprite(0, 0, 'grid');
melons = myGame.add.group();
for (var i = 0; i < 100; i++)
{
var tempSprite = myGame.add.sprite(Math.random() * myGame.world.width, Math.random() * myGame.world.height, 'melon');
tempSprite.scrollFactor.setTo(1.2, 1.2);
melons.add(tempSprite);
}
car = myGame.add.sprite(400, 300, 'car');
myGame.camera.follow(car);
}
function update() {
car.velocity.x = 0;
car.velocity.y = 0;
car.angularVelocity = 0;
car.angularAcceleration = 0;
if (myGame.input.keyboard.isDown(Phaser.Keyboard.LEFT))
{
car.angularVelocity = -200;
}
else if (myGame.input.keyboard.isDown(Phaser.Keyboard.RIGHT))
{
car.angularVelocity = 200;
}
if (myGame.input.keyboard.isDown(Phaser.Keyboard.UP))
{
var motion:Phaser.Point = myGame.motion.velocityFromAngle(car.angle, 300);
car.velocity.copyFrom(motion);
}
}
})();
-32
View File
@@ -1,32 +0,0 @@
/// <reference path="../../Phaser/Game.ts" />
(function () {
var myGame = new Phaser.Game(this, 'game', 800, 600, init, create, update);
function init() {
myGame.loader.addImageFile('atari1', 'assets/sprites/atari130xe.png');
myGame.loader.addImageFile('atari2', 'assets/sprites/atari800xl.png');
myGame.loader.addImageFile('card', 'assets/sprites/mana_card.png');
myGame.loader.load();
}
var items;
var card;
function create() {
items = myGame.add.group();
// Items are rendered in the depth order in which they are added to the Group
items.add(myGame.add.sprite(64, 100, 'atari1'));
card = items.add(myGame.add.sprite(240, 80, 'card'));
items.add(myGame.add.sprite(280, 100, 'atari2'));
myGame.input.onTap.addOnce(removeCard, this);
}
function removeCard() {
// Now let's kill the card sprite
card.kill();
myGame.input.onTap.addOnce(replaceCard, this);
}
function replaceCard() {
// And bring it back to life again - I assume it will render in the same place as before?
var bob = items.getFirstDead();
bob.revive();
}
function update() {
}
})();
-56
View File
@@ -1,56 +0,0 @@
/// <reference path="../../Phaser/Game.ts" />
(function () {
var myGame = new Phaser.Game(this, 'game', 800, 600, init, create, update);
function init() {
myGame.loader.addImageFile('atari1', 'assets/sprites/atari130xe.png');
myGame.loader.addImageFile('atari2', 'assets/sprites/atari800xl.png');
myGame.loader.addImageFile('card', 'assets/sprites/mana_card.png');
myGame.loader.load();
}
var items: Phaser.Group;
var card: Phaser.Sprite;
function create() {
items = myGame.add.group();
// Items are rendered in the depth order in which they are added to the Group
items.add(myGame.add.sprite(64, 100, 'atari1'));
card = <Phaser.Sprite> items.add(myGame.add.sprite(240, 80, 'card'));
items.add(myGame.add.sprite(280, 100, 'atari2'));
myGame.input.onTap.addOnce(removeCard, this);
}
function removeCard() {
// Now let's kill the card sprite
card.kill();
myGame.input.onTap.addOnce(replaceCard, this);
}
function replaceCard() {
// And bring it back to life again - I assume it will render in the same place as before?
var bob = items.getFirstDead();
bob.revive();
}
function update() {
}
})();
-35
View File
@@ -1,35 +0,0 @@
/// <reference path="../../Phaser/Game.ts" />
(function () {
// Here we create a quite tiny game (320x240 in size)
var myGame = new Phaser.Game(this, 'game', 320, 240, init, create, update, render);
function init() {
// This sets a limit on the up-scale
myGame.stage.scale.maxWidth = 640;
myGame.stage.scale.maxHeight = 480;
// Then we tell Phaser that we want it to scale up to whatever the browser can handle, but to do it proportionally
myGame.stage.scaleMode = Phaser.StageScaleMode.SHOW_ALL;
myGame.loader.addImageFile('melon', 'assets/sprites/melon.png');
myGame.loader.load();
}
function create() {
myGame.world.setSize(2000, 2000);
for(var i = 0; i < 1000; i++) {
myGame.add.sprite(myGame.world.randomX, myGame.world.randomY, 'melon');
}
}
function update() {
if(myGame.input.keyboard.isDown(Phaser.Keyboard.LEFT)) {
myGame.camera.scroll.x -= 4;
} else if(myGame.input.keyboard.isDown(Phaser.Keyboard.RIGHT)) {
myGame.camera.scroll.x += 4;
}
if(myGame.input.keyboard.isDown(Phaser.Keyboard.UP)) {
myGame.camera.scroll.y -= 4;
} else if(myGame.input.keyboard.isDown(Phaser.Keyboard.DOWN)) {
myGame.camera.scroll.y += 4;
}
}
function render() {
myGame.input.renderDebugInfo(16, 16);
}
})();
-62
View File
@@ -1,62 +0,0 @@
/// <reference path="../../Phaser/Game.ts" />
(function () {
// Here we create a quite tiny game (320x240 in size)
var myGame = new Phaser.Game(this, 'game', 320, 240, init, create, update, render);
function init() {
// This sets a limit on the up-scale
myGame.stage.scale.maxWidth = 640;
myGame.stage.scale.maxHeight = 480;
// Then we tell Phaser that we want it to scale up to whatever the browser can handle, but to do it proportionally
myGame.stage.scaleMode = Phaser.StageScaleMode.SHOW_ALL;
myGame.loader.addImageFile('melon', 'assets/sprites/melon.png');
myGame.loader.load();
}
function create() {
myGame.world.setSize(2000, 2000);
for (var i = 0; i < 1000; i++)
{
myGame.add.sprite(myGame.world.randomX, myGame.world.randomY, 'melon');
}
}
function update() {
if (myGame.input.keyboard.isDown(Phaser.Keyboard.LEFT))
{
myGame.camera.scroll.x -= 4;
}
else if (myGame.input.keyboard.isDown(Phaser.Keyboard.RIGHT))
{
myGame.camera.scroll.x += 4;
}
if (myGame.input.keyboard.isDown(Phaser.Keyboard.UP))
{
myGame.camera.scroll.y -= 4;
}
else if (myGame.input.keyboard.isDown(Phaser.Keyboard.DOWN))
{
myGame.camera.scroll.y += 4;
}
}
function render() {
myGame.input.renderDebugInfo(16, 16);
}
})();
-23
View File
@@ -1,23 +0,0 @@
/// <reference path="../../Phaser/Game.ts" />
(function () {
var myGame = new Phaser.Game(this, 'game', 800, 600, init, create, update, render);
function init() {
myGame.loader.addImageFile('dragonsun', 'assets/pics/cougar_dragonsun.png');
myGame.loader.load();
}
function create() {
console.log('dragons 8');
myGame.input.onDown.add(test1, this);
}
function test1() {
console.log('down');
}
function update() {
}
function render() {
myGame.input.pointer1.renderDebug();
myGame.input.pointer2.renderDebug();
myGame.input.pointer3.renderDebug();
myGame.input.pointer4.renderDebug();
}
})();
-40
View File
@@ -1,40 +0,0 @@
/// <reference path="../../Phaser/Game.ts" />
(function () {
var myGame = new Phaser.Game(this, 'game', 800, 600, init, create, update, render);
function init() {
myGame.loader.addImageFile('dragonsun', 'assets/pics/cougar_dragonsun.png');
myGame.loader.load();
}
function create() {
console.log('dragons 8');
myGame.input.onDown.add(test1, this);
}
function test1() {
console.log('down');
}
function update() {
}
function render() {
myGame.input.pointer1.renderDebug();
myGame.input.pointer2.renderDebug();
myGame.input.pointer3.renderDebug();
myGame.input.pointer4.renderDebug();
}
})();
-39
View File
@@ -1,39 +0,0 @@
/// <reference path="../../Phaser/Game.ts" />
(function () {
var myGame = new Phaser.Game(this, 'game', 800, 600, init, create, update, render);
function init() {
myGame.loader.addImageFile('ball0', 'assets/sprites/yellow_ball.png');
myGame.loader.addImageFile('ball1', 'assets/sprites/aqua_ball.png');
myGame.loader.addImageFile('ball2', 'assets/sprites/blue_ball.png');
myGame.loader.addImageFile('ball3', 'assets/sprites/green_ball.png');
myGame.loader.addImageFile('ball4', 'assets/sprites/red_ball.png');
myGame.loader.addImageFile('ball5', 'assets/sprites/purple_ball.png');
myGame.loader.load();
}
var balls;
function create() {
balls = myGame.add.group();
myGame.input.onTap.add(tapped, this);
}
function tapped(pointer, doubleTap) {
if(balls.countDead() > 0) {
var tempBall = balls.getFirstDead();
tempBall.revive();
tempBall.x = pointer.x;
tempBall.y = pointer.y;
} else {
var tempBall = new Phaser.Sprite(myGame, pointer.x, pointer.y, 'ball' + Math.round(Math.random() * 5));
tempBall.setBoundsFromWorld(Phaser.GameObject.OUT_OF_BOUNDS_KILL);
balls.add(tempBall);
}
tempBall.velocity.y = 150;
if(doubleTap) {
tempBall.scale.setTo(4, 4);
}
}
function update() {
}
function render() {
myGame.input.renderDebugInfo(16, 16);
}
})();
-64
View File
@@ -1,64 +0,0 @@
/// <reference path="../../Phaser/Game.ts" />
(function () {
var myGame = new Phaser.Game(this, 'game', 800, 600, init, create, update, render);
function init() {
myGame.loader.addImageFile('ball0', 'assets/sprites/yellow_ball.png');
myGame.loader.addImageFile('ball1', 'assets/sprites/aqua_ball.png');
myGame.loader.addImageFile('ball2', 'assets/sprites/blue_ball.png');
myGame.loader.addImageFile('ball3', 'assets/sprites/green_ball.png');
myGame.loader.addImageFile('ball4', 'assets/sprites/red_ball.png');
myGame.loader.addImageFile('ball5', 'assets/sprites/purple_ball.png');
myGame.loader.load();
}
var balls: Phaser.Group;
function create() {
balls = myGame.add.group();
myGame.input.onTap.add(tapped, this);
}
function tapped(pointer: Phaser.Pointer, doubleTap: bool) {
if (balls.countDead() > 0)
{
var tempBall: Phaser.Sprite = <Phaser.Sprite> balls.getFirstDead();
tempBall.revive();
tempBall.x = pointer.x;
tempBall.y = pointer.y;
}
else
{
var tempBall: Phaser.Sprite = new Phaser.Sprite(myGame, pointer.x, pointer.y, 'ball' + Math.round(Math.random() * 5));
tempBall.setBoundsFromWorld(Phaser.GameObject.OUT_OF_BOUNDS_KILL);
balls.add(tempBall);
}
tempBall.velocity.y = 150;
if (doubleTap)
{
tempBall.scale.setTo(4, 4);
}
}
function update() {
}
function render() {
myGame.input.renderDebugInfo(16, 16);
}
})();
-19
View File
@@ -1,19 +0,0 @@
/// <reference path="../../Phaser/Game.ts" />
(function () {
var myGame = new Phaser.Game(this, 'game', 800, 600, init, create, update, render);
function init() {
}
function create() {
// We lock the game to allowing only 1 Pointer active
// This means on multi-touch systems it will ignore any extra fingers placed down beyond the first
myGame.input.maxPointers = 1;
}
function update() {
}
function render() {
myGame.input.renderDebugInfo(16, 16);
myGame.input.pointer1.renderDebug(true);
myGame.input.pointer2.renderDebug(true);
myGame.input.pointer3.renderDebug(true);
}
})();
-31
View File
@@ -1,31 +0,0 @@
/// <reference path="../../Phaser/Game.ts" />
(function () {
var myGame = new Phaser.Game(this, 'game', 800, 600, init, create, update, render);
function init() {
}
function create() {
// We lock the game to allowing only 1 Pointer active
// This means on multi-touch systems it will ignore any extra fingers placed down beyond the first
myGame.input.maxPointers = 1;
}
function update() {
}
function render() {
myGame.input.renderDebugInfo(16, 16);
myGame.input.pointer1.renderDebug(true);
myGame.input.pointer2.renderDebug(true);
myGame.input.pointer3.renderDebug(true);
}
})();
-4
View File
@@ -1,4 +0,0 @@
/// <reference path="../../Phaser/Game.ts" />
(function () {
var myGame = new Phaser.Game(this, 'game', 800, 600);
})();
-7
View File
@@ -1,7 +0,0 @@
/// <reference path="../../Phaser/Game.ts" />
(function () {
var myGame = new Phaser.Game(this, 'game', 800, 600);
})();
-46
View File
@@ -1,46 +0,0 @@
/// <reference path="../../Phaser/Game.ts" />
(function () {
var myGame = new Phaser.Game(this, 'game', 800, 600, null, create, update, render);
var starfield;
var xx = [];
var yy = [];
var zz = [];
var xxx = 0;
var yyy = 0;
function create() {
// the width of the starfield
var star_w = 12000;
for(var i = 0; i < 800; i++) {
xx[i] = Math.floor(Math.random() * star_w * 2) - star_w;
yy[i] = Math.floor(Math.random() * star_w * 2) - star_w;
zz[i] = Math.floor(Math.random() * 160) + 1;
}
starfield = myGame.add.dynamicTexture(800, 600);
}
function update() {
starfield.clear();
for(var i = 0; i < 800; i++) {
if(zz[i] == 1) {
zz[i] = 100;
}
xxx = (xx[i]) / (zz[i]);
yyy = (yy[i]) / (zz[i])--;
//var x: number = xxx + myGame.input.x;
//var y: number = yyy + myGame.input.y;
var x = xxx + 400;
var y = yyy + 300;
var c = '#ffffff';
if(zz[i] > 80) {
c = '#666666';
} else if(zz[i] > 60) {
c = '#888888';
} else if(zz[i] > 40) {
c = '#aaaaaa';
}
starfield.setPixel(x, y, c);
}
}
function render() {
starfield.render();
}
})();
-61
View File
@@ -1,61 +0,0 @@
/// <reference path="../../Phaser/Game.ts" />
(function () {
var myGame = new Phaser.Game(this, 'game', 800, 600, null, create, update, render);
var starfield: Phaser.DynamicTexture;
var xx = [];
var yy = [];
var zz = [];
var xxx = 0;
var yyy = 0;
function create() {
// the width of the starfield
var star_w: number = 12000;
for (var i: number = 0; i < 800; i++)
{
xx[i] = Math.floor(Math.random() * star_w * 2) - star_w
yy[i] = Math.floor(Math.random() * star_w * 2) - star_w
zz[i] = Math.floor(Math.random() * 160) + 1;
}
starfield = myGame.add.dynamicTexture(800, 600);
}
function update() {
starfield.clear();
for (var i: number = 0; i < 800; i++)
{
if (zz[i] == 1) zz[i] = 100;
xxx = (xx[i]) / (zz[i]);
yyy = (yy[i]) / (zz[i])--;
//var x: number = xxx + myGame.input.x;
//var y: number = yyy + myGame.input.y;
var x: number = xxx + 400;
var y: number = yyy + 300;
var c: string = '#ffffff';
if (zz[i] > 80) c = '#666666';
else if (zz[i] > 60) c = '#888888'
else if (zz[i] > 40) c = '#aaaaaa';
starfield.setPixel(x, y, c);
}
}
function render() {
starfield.render();
}
})();
@@ -1,25 +0,0 @@
/// <reference path="../../Phaser/Game.ts" />
/// <reference path="../../Phaser/gameobjects/ScrollZone.ts" />
(function () {
var myGame = new Phaser.Game(this, 'game', 800, 600, init, create, update);
function init() {
myGame.loader.addImageFile('balls', 'assets/sprites/balls.png');
myGame.loader.load();
}
var scroller;
function create() {
// The source image (balls.png) is only 102x17 in size, but we want it to create a scroll the size of the whole game window.
// We can take advantage of the way a ScrollZone can create a seamless pattern for us automatically.
// If you create a ScrollRegion larger than the source texture, it'll create a DynamicTexture and perform a pattern fill on it and use that
// for rendering.
// We've rounded the height up to 612 because in order to have a seamless pattern it needs to be a multiple of 17 (the height of the source image)
scroller = myGame.add.scrollZone('balls', 0, 0, 800, 612);
// Some sin/cos data for the movement
myGame.math.sinCosGenerator(256, 4, 4, 2);
}
function update() {
// Cycle through the wave data and apply it to the scroll speed (causes the circular wave motion)
scroller.currentRegion.scrollSpeed.x = myGame.math.shiftSinTable();
scroller.currentRegion.scrollSpeed.y = myGame.math.shiftCosTable();
}
})();
@@ -1,41 +0,0 @@
/// <reference path="../../Phaser/Game.ts" />
/// <reference path="../../Phaser/gameobjects/ScrollZone.ts" />
(function () {
var myGame = new Phaser.Game(this, 'game', 800, 600, init, create, update);
function init() {
myGame.loader.addImageFile('balls', 'assets/sprites/balls.png');
myGame.loader.load();
}
var scroller: Phaser.ScrollZone;
function create() {
// The source image (balls.png) is only 102x17 in size, but we want it to create a scroll the size of the whole game window.
// We can take advantage of the way a ScrollZone can create a seamless pattern for us automatically.
// If you create a ScrollRegion larger than the source texture, it'll create a DynamicTexture and perform a pattern fill on it and use that
// for rendering.
// We've rounded the height up to 612 because in order to have a seamless pattern it needs to be a multiple of 17 (the height of the source image)
scroller = myGame.add.scrollZone('balls', 0, 0, 800, 612);
// Some sin/cos data for the movement
myGame.math.sinCosGenerator(256, 4, 4, 2);
}
function update() {
// Cycle through the wave data and apply it to the scroll speed (causes the circular wave motion)
scroller.currentRegion.scrollSpeed.x = myGame.math.shiftSinTable();
scroller.currentRegion.scrollSpeed.y = myGame.math.shiftCosTable();
}
})();
@@ -1,95 +0,0 @@
/// <reference path="../../Phaser/Game.ts" />
/// <reference path="../../Phaser/gameobjects/ScrollZone.ts" />
(function () {
var myGame = new Phaser.Game(this, 'game', 800, 600, init, create, update);
function init() {
myGame.loader.addImageFile('nashwan', 'assets/sprites/xenon2_ship.png');
myGame.loader.addImageFile('starfield', 'assets/misc/starfield.jpg');
myGame.loader.addImageFile('jet', 'assets/sprites/particle1.png');
myGame.loader.addImageFile('bullet', 'assets/misc/bullet1.png');
myGame.loader.load();
}
var scroller;
var emitter;
var ship;
var bullets;
var speed = 0;
var fireRate = 0;
var shipMotion;
function create() {
scroller = myGame.add.scrollZone('starfield', 0, 0, 1024, 1024);
emitter = myGame.add.emitter(myGame.stage.centerX + 16, myGame.stage.centerY + 12);
emitter.makeParticles('jet', 250, false, 0);
emitter.setRotation(0, 0);
// Looks like a smoke trail!
//emitter.globalCompositeOperation = 'xor';
// Looks way cool :)
emitter.globalCompositeOperation = 'lighter';
bullets = myGame.add.group(50);
// Create our bullet pool
for(var i = 0; i < 50; i++) {
var tempBullet = new Phaser.Sprite(myGame, myGame.stage.centerX, myGame.stage.centerY, 'bullet');
tempBullet.exists = false;
tempBullet.rotationOffset = 90;
tempBullet.setBounds(-100, -100, 900, 700);
tempBullet.outOfBoundsAction = Phaser.GameObject.OUT_OF_BOUNDS_KILL;
bullets.add(tempBullet);
}
ship = myGame.add.sprite(myGame.stage.centerX, myGame.stage.centerY, 'nashwan');
// We do this because the ship was drawn facing up, but 0 degrees is pointing to the right
ship.rotationOffset = 90;
myGame.input.onDown.add(test, this);
}
function test(event) {
myGame.stage.scale.startFullScreen();
}
function update() {
ship.angularVelocity = 0;
if(myGame.input.keyboard.isDown(Phaser.Keyboard.LEFT)) {
ship.angularVelocity = -200;
} else if(myGame.input.keyboard.isDown(Phaser.Keyboard.RIGHT)) {
ship.angularVelocity = 200;
}
if(myGame.input.keyboard.isDown(Phaser.Keyboard.UP)) {
speed += 0.1;
if(speed > 10) {
speed = 10;
}
} else {
speed -= 0.1;
if(speed < 0) {
speed = 0;
}
}
shipMotion = myGame.motion.velocityFromAngle(ship.angle, speed);
scroller.setSpeed(shipMotion.x, shipMotion.y);
// emit particles
if(speed > 2) {
// We use the opposite of the motion because the jets emit out the back of the ship
// The 20 and 30 values just keep them nice and fast
emitter.setXSpeed(-(shipMotion.x * 20), -(shipMotion.x * 30));
emitter.setYSpeed(-(shipMotion.y * 20), -(shipMotion.y * 30));
emitter.emitParticle();
}
if(myGame.input.keyboard.isDown(Phaser.Keyboard.SPACEBAR)) {
fire();
}
}
function recycleBullet(bullet) {
if(bullet.exists && bullet.x < -40 || bullet.x > 840 || bullet.y < -40 || bullet.y > 640) {
bullet.exists = false;
}
}
function fire() {
if(myGame.time.now > fireRate) {
var b = bullets.getFirstAvailable();
b.x = ship.x;
b.y = ship.y - 26;
var bulletMotion = myGame.motion.velocityFromAngle(ship.angle, 400);
b.revive();
b.angle = ship.angle;
b.velocity.setTo(bulletMotion.x, bulletMotion.y);
fireRate = myGame.time.now + 100;
}
}
})();
@@ -1,151 +0,0 @@
/// <reference path="../../Phaser/Game.ts" />
/// <reference path="../../Phaser/gameobjects/ScrollZone.ts" />
(function () {
var myGame = new Phaser.Game(this, 'game', 800, 600, init, create, update);
function init() {
myGame.loader.addImageFile('nashwan', 'assets/sprites/xenon2_ship.png');
myGame.loader.addImageFile('starfield', 'assets/misc/starfield.jpg');
myGame.loader.addImageFile('jet', 'assets/sprites/particle1.png');
myGame.loader.addImageFile('bullet', 'assets/misc/bullet1.png');
myGame.loader.load();
}
var scroller: Phaser.ScrollZone;
var emitter: Phaser.Emitter;
var ship: Phaser.Sprite;
var bullets: Phaser.Group;
var speed: number = 0;
var fireRate: number = 0;
var shipMotion: Phaser.Point;
function create() {
scroller = myGame.add.scrollZone('starfield', 0, 0, 1024, 1024);
emitter = myGame.add.emitter(myGame.stage.centerX + 16, myGame.stage.centerY + 12);
emitter.makeParticles('jet', 250, false, 0);
emitter.setRotation(0, 0);
// Looks like a smoke trail!
//emitter.globalCompositeOperation = 'xor';
// Looks way cool :)
emitter.globalCompositeOperation = 'lighter';
bullets = myGame.add.group(50);
// Create our bullet pool
for (var i = 0; i < 50; i++)
{
var tempBullet = new Phaser.Sprite(myGame, myGame.stage.centerX, myGame.stage.centerY, 'bullet');
tempBullet.exists = false;
tempBullet.rotationOffset = 90;
tempBullet.setBounds(-100, -100, 900, 700);
tempBullet.outOfBoundsAction = Phaser.GameObject.OUT_OF_BOUNDS_KILL;
bullets.add(tempBullet);
}
ship = myGame.add.sprite(myGame.stage.centerX, myGame.stage.centerY, 'nashwan');
// We do this because the ship was drawn facing up, but 0 degrees is pointing to the right
ship.rotationOffset = 90;
myGame.input.onDown.add(test, this);
}
function test(event) {
myGame.stage.scale.startFullScreen();
}
function update() {
ship.angularVelocity = 0;
if (myGame.input.keyboard.isDown(Phaser.Keyboard.LEFT))
{
ship.angularVelocity = -200;
}
else if (myGame.input.keyboard.isDown(Phaser.Keyboard.RIGHT))
{
ship.angularVelocity = 200;
}
if (myGame.input.keyboard.isDown(Phaser.Keyboard.UP))
{
speed += 0.1;
if (speed > 10)
{
speed = 10;
}
}
else
{
speed -= 0.1;
if (speed < 0) {
speed = 0;
}
}
shipMotion = myGame.motion.velocityFromAngle(ship.angle, speed);
scroller.setSpeed(shipMotion.x, shipMotion.y);
// emit particles
if (speed > 2)
{
// We use the opposite of the motion because the jets emit out the back of the ship
// The 20 and 30 values just keep them nice and fast
emitter.setXSpeed(-(shipMotion.x * 20), -(shipMotion.x * 30));
emitter.setYSpeed(-(shipMotion.y * 20), -(shipMotion.y * 30));
emitter.emitParticle();
}
if (myGame.input.keyboard.isDown(Phaser.Keyboard.SPACEBAR))
{
fire();
}
}
function recycleBullet(bullet:Phaser.Sprite) {
if (bullet.exists && bullet.x < -40 || bullet.x > 840 || bullet.y < -40 || bullet.y > 640)
{
bullet.exists = false;
}
}
function fire() {
if (myGame.time.now > fireRate)
{
var b:Phaser.Sprite = bullets.getFirstAvailable();
b.x = ship.x;
b.y = ship.y - 26;
var bulletMotion = myGame.motion.velocityFromAngle(ship.angle, 400);
b.revive();
b.angle = ship.angle;
b.velocity.setTo(bulletMotion.x, bulletMotion.y);
fireRate = myGame.time.now + 100;
}
}
})();
-31
View File
@@ -1,31 +0,0 @@
/// <reference path="../../Phaser/Game.ts" />
/// <reference path="../../Phaser/gameobjects/ScrollZone.ts" />
(function () {
var myGame = new Phaser.Game(this, 'game', 800, 600, init, create);
function init() {
myGame.loader.addImageFile('starray', 'assets/pics/auto_scroll_landscape.png');
myGame.loader.load();
}
function create() {
var zone = myGame.add.scrollZone('starray');
// Hide the default region (the full image)
zone.currentRegion.visible = false;
var y = 0;
var speed = 16;
// The image consists of 10px high scrolling layers, this creates them quickly (top = fastest, getting slower as we move down)
for(var z = 0; z < 32; z++) {
zone.addRegion(0, y, 640, 10, speed);
if(z <= 15) {
speed -= 1;
} else {
speed += 1;
}
if(z == 15) {
y = 240;
speed += 1;
} else {
y += 10;
}
}
}
})();
-53
View File
@@ -1,53 +0,0 @@
/// <reference path="../../Phaser/Game.ts" />
/// <reference path="../../Phaser/gameobjects/ScrollZone.ts" />
(function () {
var myGame = new Phaser.Game(this, 'game', 800, 600, init, create);
function init() {
myGame.loader.addImageFile('starray', 'assets/pics/auto_scroll_landscape.png');
myGame.loader.load();
}
function create() {
var zone: Phaser.ScrollZone = myGame.add.scrollZone('starray');
// Hide the default region (the full image)
zone.currentRegion.visible = false;
var y:number = 0;
var speed:number = 16;
// The image consists of 10px high scrolling layers, this creates them quickly (top = fastest, getting slower as we move down)
for (var z:number = 0; z < 32; z++)
{
zone.addRegion(0, y, 640, 10, speed);
if (z <= 15)
{
speed -= 1;
}
else
{
speed += 1;
}
if (z == 15)
{
y = 240;
speed += 1;
}
else
{
y += 10;
}
}
}
})();
@@ -1,22 +0,0 @@
/// <reference path="../../Phaser/Game.ts" />
/// <reference path="../../Phaser/gameobjects/ScrollZone.ts" />
(function () {
var myGame = new Phaser.Game(this, 'game', 800, 600, init, create);
function init() {
myGame.loader.addImageFile('angelDawn', 'assets/pics/game14_angel_dawn.png');
myGame.loader.load();
}
var scroller;
function create() {
// This creates our ScrollZone centered in the middle of the stage.
scroller = myGame.add.scrollZone('angelDawn', myGame.stage.centerX - 320, 100);
// By default we won't scroll the full image, but we will create 3 ScrollRegions within it:
// This creates a ScrollRegion which can be thought of as a rectangle within the ScrollZone that can be scrolled
// independantly - this one scrolls the image of the spacemans head
scroller.addRegion(32, 32, 352, 240, 0, 2);
// The head in the top right
scroller.addRegion(480, 30, 96, 96, 4, 0);
// The small piece of text
scroller.addRegion(466, 160, 122, 14, 0, -0.5);
}
})();
@@ -1,37 +0,0 @@
/// <reference path="../../Phaser/Game.ts" />
/// <reference path="../../Phaser/gameobjects/ScrollZone.ts" />
(function () {
var myGame = new Phaser.Game(this, 'game', 800, 600, init, create);
function init() {
myGame.loader.addImageFile('angelDawn', 'assets/pics/game14_angel_dawn.png');
myGame.loader.load();
}
var scroller: Phaser.ScrollZone;
function create() {
// This creates our ScrollZone centered in the middle of the stage.
scroller = myGame.add.scrollZone('angelDawn', myGame.stage.centerX - 320, 100);
// By default we won't scroll the full image, but we will create 3 ScrollRegions within it:
// This creates a ScrollRegion which can be thought of as a rectangle within the ScrollZone that can be scrolled
// independantly - this one scrolls the image of the spacemans head
scroller.addRegion(32, 32, 352, 240, 0, 2);
// The head in the top right
scroller.addRegion(480, 30, 96, 96, 4, 0);
// The small piece of text
scroller.addRegion(466, 160, 122, 14, 0, -0.5);
}
})();
@@ -1,18 +0,0 @@
/// <reference path="../../Phaser/Game.ts" />
/// <reference path="../../Phaser/gameobjects/ScrollZone.ts" />
(function () {
var myGame = new Phaser.Game(this, 'game', 800, 600, init, create);
function init() {
myGame.loader.addImageFile('dragonsun', 'assets/pics/cougar_dragonsun.png');
myGame.loader.addImageFile('overlay', 'assets/pics/scrollframe.png');
myGame.loader.load();
}
var scroller;
function create() {
// This creates our ScrollZone. It is positioned at x32 y32 (world coodinates)
// and is a size of 352x240 (which matches the window in our overlay image)
scroller = myGame.add.scrollZone('dragonsun', 32, 32, 352, 240);
scroller.setSpeed(2, 2);
myGame.add.sprite(0, 0, 'overlay');
}
})();
@@ -1,31 +0,0 @@
/// <reference path="../../Phaser/Game.ts" />
/// <reference path="../../Phaser/gameobjects/ScrollZone.ts" />
(function () {
var myGame = new Phaser.Game(this, 'game', 800, 600, init, create);
function init() {
myGame.loader.addImageFile('dragonsun', 'assets/pics/cougar_dragonsun.png');
myGame.loader.addImageFile('overlay', 'assets/pics/scrollframe.png');
myGame.loader.load();
}
var scroller: Phaser.ScrollZone;
function create() {
// This creates our ScrollZone. It is positioned at x32 y32 (world coodinates)
// and is a size of 352x240 (which matches the window in our overlay image)
scroller = myGame.add.scrollZone('dragonsun', 32, 32, 352, 240);
scroller.setSpeed(2, 2);
myGame.add.sprite(0, 0, 'overlay');
}
})();
@@ -1,16 +0,0 @@
/// <reference path="../../Phaser/Game.ts" />
/// <reference path="../../Phaser/gameobjects/ScrollZone.ts" />
(function () {
var myGame = new Phaser.Game(this, 'game', 800, 600, init, create);
function init() {
myGame.loader.addImageFile('crystal', 'assets/pics/jim_sachs_time_crystal.png');
myGame.loader.load();
}
function create() {
// This creates our ScrollZone. It is positioned at x0 y0 (world coodinates) by default and uses
// the 'crystal' image from the cache.
// The default is for the scroll zone to create 1 new scrolling region the size of the whole image you gave it.
// For this example we'll keep that, but look at the other tests to see reasons why you may not want to.
myGame.add.scrollZone('crystal').setSpeed(4, 2);
}
})();
@@ -1,28 +0,0 @@
/// <reference path="../../Phaser/Game.ts" />
/// <reference path="../../Phaser/gameobjects/ScrollZone.ts" />
(function () {
var myGame = new Phaser.Game(this, 'game', 800, 600, init, create);
function init() {
myGame.loader.addImageFile('crystal', 'assets/pics/jim_sachs_time_crystal.png');
myGame.loader.load();
}
function create() {
// This creates our ScrollZone. It is positioned at x0 y0 (world coodinates) by default and uses
// the 'crystal' image from the cache.
// The default is for the scroll zone to create 1 new scrolling region the size of the whole image you gave it.
// For this example we'll keep that, but look at the other tests to see reasons why you may not want to.
myGame.add.scrollZone('crystal').setSpeed(4, 2);
}
})();
-27
View File
@@ -1,27 +0,0 @@
/// <reference path="../../Phaser/Game.ts" />
(function () {
var myGame = new Phaser.Game(this, 'game', 800, 600, init, create, update);
function init() {
myGame.loader.addImageFile('teddy', 'assets/pics/profil-sad_plush.png');
myGame.loader.load();
}
var teddy;
function create() {
teddy = myGame.add.sprite(0, 0, 'teddy');
teddy.x = myGame.stage.centerX - teddy.width / 2;
teddy.y = myGame.stage.centerY - teddy.height / 2;
myGame.input.onDown.add(click, this);
teddy.renderDebug = true;
}
function click() {
if(teddy.align == Phaser.GameObject.ALIGN_BOTTOM_RIGHT) {
teddy.align = Phaser.GameObject.ALIGN_TOP_LEFT;
} else {
teddy.align++;
}
}
function update() {
teddy.x = myGame.input.x;
teddy.y = myGame.input.y;
}
})();
-50
View File
@@ -1,50 +0,0 @@
/// <reference path="../../Phaser/Game.ts" />
(function () {
var myGame = new Phaser.Game(this, 'game', 800, 600, init, create, update);
function init() {
myGame.loader.addImageFile('teddy', 'assets/pics/profil-sad_plush.png');
myGame.loader.load();
}
var teddy: Phaser.Sprite;
function create() {
teddy = myGame.add.sprite(0, 0, 'teddy');
teddy.x = myGame.stage.centerX - teddy.width / 2;
teddy.y = myGame.stage.centerY - teddy.height / 2;
myGame.input.onDown.add(click, this);
teddy.renderDebug = true;
}
function click() {
if (teddy.align == Phaser.GameObject.ALIGN_BOTTOM_RIGHT)
{
teddy.align = Phaser.GameObject.ALIGN_TOP_LEFT;
}
else
{
teddy.align++;
}
}
function update() {
teddy.x = myGame.input.x;
teddy.y = myGame.input.y;
}
})();
@@ -1,34 +0,0 @@
/// <reference path="../../Phaser/Game.ts" />
(function () {
var myGame = new Phaser.Game(this, 'game', 800, 600, init, create, update);
function init() {
myGame.loader.addTextureAtlas('bot', 'assets/sprites/running_bot.png', 'assets/sprites/running_bot.json');
myGame.loader.load();
}
var bot;
function create() {
bot = myGame.add.sprite(myGame.stage.width, 300, 'bot');
// If you are using a Texture Atlas and want to specify the frames of an animation by their name rather than frame index
// then you can use this format:
bot.animations.add('run', [
'run00',
'run01',
'run02',
'run03',
'run04',
'run05',
'run06',
'run07',
'run08',
'run09',
'run10'
], 10, true, false);
bot.animations.play('run');
bot.velocity.x = -100;
}
function update() {
if(bot.x < -bot.width) {
bot.x = myGame.stage.width;
}
}
})();
@@ -1,40 +0,0 @@
/// <reference path="../../Phaser/Game.ts" />
(function () {
var myGame = new Phaser.Game(this, 'game', 800, 600, init, create, update);
function init() {
myGame.loader.addTextureAtlas('bot', 'assets/sprites/running_bot.png', 'assets/sprites/running_bot.json');
myGame.loader.load();
}
var bot: Phaser.Sprite;
function create() {
bot = myGame.add.sprite(myGame.stage.width, 300, 'bot');
// If you are using a Texture Atlas and want to specify the frames of an animation by their name rather than frame index
// then you can use this format:
bot.animations.add('run', ['run00', 'run01', 'run02', 'run03', 'run04', 'run05', 'run06', 'run07', 'run08', 'run09', 'run10'], 10, true, false);
bot.animations.play('run');
bot.velocity.x = -100;
}
function update() {
if (bot.x < -bot.width)
{
bot.x = myGame.stage.width;
}
}
})();
@@ -1,59 +0,0 @@
/// <reference path="../../Phaser/Game.ts" />
(function () {
var myGame = new Phaser.Game(this, 'game', 800, 600, init, create, update);
function init() {
myGame.loader.addImageFile('ball', 'assets/sprites/shinyball.png');
myGame.loader.load();
}
var wobblyBall;
function create() {
// Create our DynamicTexture
wobblyBall = myGame.add.dynamicTexture(32, 64);
// And apply it to 100 randomly positioned sprites
for(var i = 0; i < 100; i++) {
var temp = myGame.add.sprite(myGame.world.randomX, myGame.world.randomY);
temp.width = 32;
temp.height = 64;
temp.loadDynamicTexture(wobblyBall);
}
// Populate the wave with some data
waveData = myGame.math.sinCosGenerator(32, 8, 8, 2);
}
function update() {
wobblyBall.clear();
updateWobblyBall();
}
// This creates a simple sine-wave effect running through our DynamicTexture.
// This is then duplicated across all sprites using it, meaning we only have to calculate it once.
var waveSize = 8;
var wavePixelChunk = 2;
var waveData;
var waveDataCounter;
function updateWobblyBall() {
var s = 0;
var copyRect = {
x: 0,
y: 0,
w: wavePixelChunk,
h: 32
};
var copyPoint = {
x: 0,
y: 0
};
for(var x = 0; x < 32; x += wavePixelChunk) {
copyPoint.x = x;
copyPoint.y = waveSize + (waveSize / 2) + waveData[s];
wobblyBall.context.drawImage(myGame.cache.getImage('ball'), copyRect.x, copyRect.y, copyRect.w, copyRect.h, copyPoint.x, copyPoint.y, copyRect.w, copyRect.h);
copyRect.x += wavePixelChunk;
s++;
}
// Cycle through the wave data - this is what causes the image to "undulate"
var t = waveData.shift();
waveData.push(t);
waveDataCounter++;
if(waveDataCounter == waveData.length) {
waveDataCounter = 0;
}
}
})();
@@ -1,82 +0,0 @@
/// <reference path="../../Phaser/Game.ts" />
(function () {
var myGame = new Phaser.Game(this, 'game', 800, 600, init, create, update);
function init() {
myGame.loader.addImageFile('ball', 'assets/sprites/shinyball.png');
myGame.loader.load();
}
var wobblyBall: Phaser.DynamicTexture;
function create() {
// Create our DynamicTexture
wobblyBall = myGame.add.dynamicTexture(32, 64);
// And apply it to 100 randomly positioned sprites
for (var i = 0; i < 100; i++)
{
var temp = myGame.add.sprite(myGame.world.randomX, myGame.world.randomY);
temp.width = 32;
temp.height = 64;
temp.loadDynamicTexture(wobblyBall);
}
// Populate the wave with some data
waveData = myGame.math.sinCosGenerator(32, 8, 8, 2);
}
function update() {
wobblyBall.clear();
updateWobblyBall();
}
// This creates a simple sine-wave effect running through our DynamicTexture.
// This is then duplicated across all sprites using it, meaning we only have to calculate it once.
var waveSize = 8;
var wavePixelChunk = 2;
var waveData;
var waveDataCounter;
function updateWobblyBall()
{
var s = 0;
var copyRect = { x: 0, y: 0, w: wavePixelChunk, h: 32 };
var copyPoint = { x: 0, y: 0 };
for (var x = 0; x < 32; x += wavePixelChunk)
{
copyPoint.x = x;
copyPoint.y = waveSize + (waveSize / 2) + waveData[s];
wobblyBall.context.drawImage(myGame.cache.getImage('ball'), copyRect.x, copyRect.y, copyRect.w, copyRect.h, copyPoint.x, copyPoint.y, copyRect.w, copyRect.h);
copyRect.x += wavePixelChunk;
s++;
}
// Cycle through the wave data - this is what causes the image to "undulate"
var t = waveData.shift();
waveData.push(t);
waveDataCounter++;
if (waveDataCounter == waveData.length)
{
waveDataCounter = 0;
}
}
})();
@@ -1,32 +0,0 @@
/// <reference path="../../Phaser/Game.ts" />
(function () {
var myGame = new Phaser.Game(this, 'game', 800, 600, init, create, update);
function init() {
// Starling/Sparrow XML Texture Atlas Method 1
//
// In this example we assume that the XML data is stored in an external file
myGame.loader.addTextureAtlas('bits', 'assets/sprites/shoebox.png', 'assets/sprites/shoebox.xml', null, Phaser.Loader.TEXTURE_ATLAS_XML_STARLING);
myGame.loader.addTextureAtlas('bot', 'assets/sprites/shoebot.png', 'assets/sprites/shoebot.xml', null, Phaser.Loader.TEXTURE_ATLAS_XML_STARLING);
myGame.loader.load();
}
var bits;
var bot;
function create() {
bot = myGame.add.sprite(800, 200, 'bot');
bot.animations.add('run');
bot.animations.play('run', 10, true);
bits = myGame.add.sprite(200, 200, 'bits');
bits.frame = 0;
bot.velocity.x = -300;
}
function update() {
if(bot.x < -bot.width) {
bot.x = myGame.stage.width;
bits.frame++;
console.log(bits.frame, bits.animations.frameTotal);
if(bits.frame == bits.animations.frameTotal - 1) {
bits.frame = 0;
}
}
}
})();
@@ -1,52 +0,0 @@
/// <reference path="../../Phaser/Game.ts" />
(function () {
var myGame = new Phaser.Game(this, 'game', 800, 600, init, create, update);
function init() {
// Starling/Sparrow XML Texture Atlas Method 1
//
// In this example we assume that the XML data is stored in an external file
myGame.loader.addTextureAtlas('bits', 'assets/sprites/shoebox.png', 'assets/sprites/shoebox.xml', null, Phaser.Loader.TEXTURE_ATLAS_XML_STARLING);
myGame.loader.addTextureAtlas('bot', 'assets/sprites/shoebot.png', 'assets/sprites/shoebot.xml', null, Phaser.Loader.TEXTURE_ATLAS_XML_STARLING);
myGame.loader.load();
}
var bits: Phaser.Sprite;
var bot: Phaser.Sprite;
function create() {
bot = myGame.add.sprite(800, 200, 'bot');
bot.animations.add('run');
bot.animations.play('run', 10, true);
bits = myGame.add.sprite(200, 200, 'bits');
bits.frame = 0;
bot.velocity.x = -300;
}
function update() {
if (bot.x < -bot.width)
{
bot.x = myGame.stage.width;
bits.frame++;
console.log(bits.frame, bits.animations.frameTotal);
if (bits.frame == bits.animations.frameTotal - 1)
{
bits.frame = 0;
}
}
}
})();
@@ -1,25 +0,0 @@
/// <reference path="../../Phaser/Game.ts" />
(function () {
var myGame = new Phaser.Game(this, 'game', 800, 600, init, create, update);
function init() {
// Texture Atlas Method 2
//
// In this example we assume that the TexturePacker JSON data is a string of json data stored as a var
// (in this case botData)
myGame.loader.addTextureAtlas('bot', 'assets/sprites/running_bot.png', null, botData);
myGame.loader.load();
}
var bot;
function create() {
bot = myGame.add.sprite(myGame.stage.width, 300, 'bot');
bot.animations.add('run');
bot.animations.play('run', 10, true);
bot.velocity.x = -100;
}
function update() {
if(bot.x < -bot.width) {
bot.x = myGame.stage.width;
}
}
var botData = '{"frames": [{"filename": "running bot.swf/0000","frame": { "x": 34, "y": 128, "w": 56, "h": 60 },"rotated": false,"trimmed": true,"spriteSourceSize": { "x": 0, "y": 2, "w": 56, "h": 60 },"sourceSize": { "w": 56, "h": 64 }},{"filename": "running bot.swf/0001","frame": { "x": 54, "y": 0, "w": 56, "h": 58 },"rotated": false,"trimmed": true,"spriteSourceSize": { "x": 0, "y": 3, "w": 56, "h": 58 },"sourceSize": { "w": 56, "h": 64 }},{"filename": "running bot.swf/0002","frame": { "x": 54, "y": 58, "w": 56, "h": 58 },"rotated": false,"trimmed": true,"spriteSourceSize": { "x": 0, "y": 3, "w": 56, "h": 58 },"sourceSize": { "w": 56, "h": 64 }},{"filename": "running bot.swf/0003","frame": { "x": 0, "y": 192, "w": 34, "h": 64 },"rotated": false,"trimmed": true,"spriteSourceSize": { "x": 11, "y": 0, "w": 34, "h": 64 },"sourceSize": { "w": 56, "h": 64 }},{"filename": "running bot.swf/0004","frame": { "x": 0, "y": 64, "w": 54, "h": 64 },"rotated": false,"trimmed": true,"spriteSourceSize": { "x": 1, "y": 0, "w": 54, "h": 64 },"sourceSize": { "w": 56, "h": 64 }},{"filename": "running bot.swf/0005","frame": { "x": 196, "y": 0, "w": 56, "h": 58 },"rotated": false,"trimmed": true,"spriteSourceSize": { "x": 0, "y": 3, "w": 56, "h": 58 },"sourceSize": { "w": 56, "h": 64 }},{"filename": "running bot.swf/0006","frame": { "x": 0, "y": 0, "w": 54, "h": 64 },"rotated": false,"trimmed": true,"spriteSourceSize": { "x": 1, "y": 0, "w": 54, "h": 64 },"sourceSize": { "w": 56, "h": 64 }},{"filename": "running bot.swf/0007","frame": { "x": 140, "y": 0, "w": 56, "h": 58 },"rotated": false,"trimmed": true,"spriteSourceSize": { "x": 0, "y": 3, "w": 56, "h": 58 },"sourceSize": { "w": 56, "h": 64 }},{"filename": "running bot.swf/0008","frame": { "x": 34, "y": 188, "w": 50, "h": 60 },"rotated": false,"trimmed": true,"spriteSourceSize": { "x": 3, "y": 2, "w": 50, "h": 60 },"sourceSize": { "w": 56, "h": 64 }},{"filename": "running bot.swf/0009","frame": { "x": 0, "y": 128, "w": 34, "h": 64 },"rotated": false,"trimmed": true,"spriteSourceSize": { "x": 11, "y": 0, "w": 34, "h": 64 },"sourceSize": { "w": 56, "h": 64 }},{"filename": "running bot.swf/0010","frame": { "x": 84, "y": 188, "w": 56, "h": 58 },"rotated": false,"trimmed": true,"spriteSourceSize": { "x": 0, "y": 3, "w": 56, "h": 58 },"sourceSize": { "w": 56, "h": 64 }}]}';
})();
@@ -1,43 +0,0 @@
/// <reference path="../../Phaser/Game.ts" />
(function () {
var myGame = new Phaser.Game(this, 'game', 800, 600, init, create, update);
function init() {
// Texture Atlas Method 2
//
// In this example we assume that the TexturePacker JSON data is a string of json data stored as a var
// (in this case botData)
myGame.loader.addTextureAtlas('bot', 'assets/sprites/running_bot.png', null, botData);
myGame.loader.load();
}
var bot: Phaser.Sprite;
function create() {
bot = myGame.add.sprite(myGame.stage.width, 300, 'bot');
bot.animations.add('run');
bot.animations.play('run', 10, true);
bot.velocity.x = -100;
}
function update() {
if (bot.x < -bot.width)
{
bot.x = myGame.stage.width;
}
}
var botData = '{"frames": [{"filename": "running bot.swf/0000","frame": { "x": 34, "y": 128, "w": 56, "h": 60 },"rotated": false,"trimmed": true,"spriteSourceSize": { "x": 0, "y": 2, "w": 56, "h": 60 },"sourceSize": { "w": 56, "h": 64 }},{"filename": "running bot.swf/0001","frame": { "x": 54, "y": 0, "w": 56, "h": 58 },"rotated": false,"trimmed": true,"spriteSourceSize": { "x": 0, "y": 3, "w": 56, "h": 58 },"sourceSize": { "w": 56, "h": 64 }},{"filename": "running bot.swf/0002","frame": { "x": 54, "y": 58, "w": 56, "h": 58 },"rotated": false,"trimmed": true,"spriteSourceSize": { "x": 0, "y": 3, "w": 56, "h": 58 },"sourceSize": { "w": 56, "h": 64 }},{"filename": "running bot.swf/0003","frame": { "x": 0, "y": 192, "w": 34, "h": 64 },"rotated": false,"trimmed": true,"spriteSourceSize": { "x": 11, "y": 0, "w": 34, "h": 64 },"sourceSize": { "w": 56, "h": 64 }},{"filename": "running bot.swf/0004","frame": { "x": 0, "y": 64, "w": 54, "h": 64 },"rotated": false,"trimmed": true,"spriteSourceSize": { "x": 1, "y": 0, "w": 54, "h": 64 },"sourceSize": { "w": 56, "h": 64 }},{"filename": "running bot.swf/0005","frame": { "x": 196, "y": 0, "w": 56, "h": 58 },"rotated": false,"trimmed": true,"spriteSourceSize": { "x": 0, "y": 3, "w": 56, "h": 58 },"sourceSize": { "w": 56, "h": 64 }},{"filename": "running bot.swf/0006","frame": { "x": 0, "y": 0, "w": 54, "h": 64 },"rotated": false,"trimmed": true,"spriteSourceSize": { "x": 1, "y": 0, "w": 54, "h": 64 },"sourceSize": { "w": 56, "h": 64 }},{"filename": "running bot.swf/0007","frame": { "x": 140, "y": 0, "w": 56, "h": 58 },"rotated": false,"trimmed": true,"spriteSourceSize": { "x": 0, "y": 3, "w": 56, "h": 58 },"sourceSize": { "w": 56, "h": 64 }},{"filename": "running bot.swf/0008","frame": { "x": 34, "y": 188, "w": 50, "h": 60 },"rotated": false,"trimmed": true,"spriteSourceSize": { "x": 3, "y": 2, "w": 50, "h": 60 },"sourceSize": { "w": 56, "h": 64 }},{"filename": "running bot.swf/0009","frame": { "x": 0, "y": 128, "w": 34, "h": 64 },"rotated": false,"trimmed": true,"spriteSourceSize": { "x": 11, "y": 0, "w": 34, "h": 64 },"sourceSize": { "w": 56, "h": 64 }},{"filename": "running bot.swf/0010","frame": { "x": 84, "y": 188, "w": 56, "h": 58 },"rotated": false,"trimmed": true,"spriteSourceSize": { "x": 0, "y": 3, "w": 56, "h": 58 },"sourceSize": { "w": 56, "h": 64 }}]}';
})();
@@ -1,23 +0,0 @@
/// <reference path="../../Phaser/Game.ts" />
(function () {
var myGame = new Phaser.Game(this, 'game', 800, 600, init, create, update);
function init() {
// Texture Atlas Method 3
//
// In this example we assume that the TexturePacker JSON data is stored in an external file
myGame.loader.addTextureAtlas('bot', 'assets/sprites/running_bot.png', 'assets/sprites/running_bot.json');
myGame.loader.load();
}
var bot;
function create() {
bot = myGame.add.sprite(myGame.stage.width, 300, 'bot');
bot.animations.add('run');
bot.animations.play('run', 10, true);
bot.velocity.x = -100;
}
function update() {
if(bot.x < -bot.width) {
bot.x = myGame.stage.width;
}
}
})();
@@ -1,40 +0,0 @@
/// <reference path="../../Phaser/Game.ts" />
(function () {
var myGame = new Phaser.Game(this, 'game', 800, 600, init, create, update);
function init() {
// Texture Atlas Method 3
//
// In this example we assume that the TexturePacker JSON data is stored in an external file
myGame.loader.addTextureAtlas('bot', 'assets/sprites/running_bot.png', 'assets/sprites/running_bot.json');
myGame.loader.load();
}
var bot: Phaser.Sprite;
function create() {
bot = myGame.add.sprite(myGame.stage.width, 300, 'bot');
bot.animations.add('run');
bot.animations.play('run', 10, true);
bot.velocity.x = -100;
}
function update() {
if (bot.x < -bot.width)
{
bot.x = myGame.stage.width;
}
}
})();
@@ -1,32 +0,0 @@
/// <reference path="../../Phaser/Game.ts" />
(function () {
var myGame = new Phaser.Game(this, 'game', 800, 600, init, create);
function init() {
// Texture Atlas Method 4
//
// We load a TexturePacker JSON file and image and show you how to make several unique sprites from the same file
myGame.loader.addTextureAtlas('atlas', 'assets/pics/texturepacker_test.png', 'assets/pics/texturepacker_test.json');
myGame.loader.load();
}
var chick;
var car;
var mech;
var robot;
var cop;
function create() {
myGame.camera.backgroundColor = 'rgb(40, 40, 40)';
chick = myGame.add.sprite(64, 64, 'atlas');
// You can set the frame based on the frame name (which TexturePacker usually sets to be the filename of the image itself)
chick.frameName = 'budbrain_chick.png';
// Or by setting the frame index
//chick.frame = 0;
cop = myGame.add.sprite(600, 64, 'atlas');
cop.frameName = 'ladycop.png';
robot = myGame.add.sprite(50, 300, 'atlas');
robot.frameName = 'robot.png';
car = myGame.add.sprite(100, 400, 'atlas');
car.frameName = 'supercars_parsec.png';
mech = myGame.add.sprite(250, 100, 'atlas');
mech.frameName = 'titan_mech.png';
}
})();
@@ -1,50 +0,0 @@
/// <reference path="../../Phaser/Game.ts" />
(function () {
var myGame = new Phaser.Game(this, 'game', 800, 600, init, create);
function init() {
// Texture Atlas Method 4
//
// We load a TexturePacker JSON file and image and show you how to make several unique sprites from the same file
myGame.loader.addTextureAtlas('atlas', 'assets/pics/texturepacker_test.png', 'assets/pics/texturepacker_test.json');
myGame.loader.load();
}
var chick: Phaser.Sprite;
var car: Phaser.Sprite;
var mech: Phaser.Sprite;
var robot: Phaser.Sprite;
var cop: Phaser.Sprite;
function create() {
myGame.camera.backgroundColor = 'rgb(40, 40, 40)';
chick = myGame.add.sprite(64, 64, 'atlas');
// You can set the frame based on the frame name (which TexturePacker usually sets to be the filename of the image itself)
chick.frameName = 'budbrain_chick.png';
// Or by setting the frame index
//chick.frame = 0;
cop = myGame.add.sprite(600, 64, 'atlas');
cop.frameName = 'ladycop.png';
robot = myGame.add.sprite(50, 300, 'atlas');
robot.frameName = 'robot.png';
car = myGame.add.sprite(100, 400, 'atlas');
car.frameName = 'supercars_parsec.png';
mech = myGame.add.sprite(250, 100, 'atlas');
mech.frameName = 'titan_mech.png';
}
})();
-271
View File
@@ -1,271 +0,0 @@
/// <reference path="../../Phaser/Game.ts" />
(function () {
var myGame = new Phaser.Game(this, 'game', 800, 600, init, create, update);
function init() {
// Texture Atlas Method 1
//
// In this example we assume that the TexturePacker JSON data is a real json object stored as a var
// (in this case botData)
myGame.loader.addTextureAtlas('bot', 'assets/sprites/running_bot.png', null, botData);
myGame.loader.load();
}
var bot;
function create() {
bot = myGame.add.sprite(myGame.stage.width, 300, 'bot');
bot.animations.add('run');
bot.animations.play('run', 10, true);
bot.velocity.x = -100;
}
function update() {
if(bot.x < -bot.width) {
bot.x = myGame.stage.width;
}
}
var botData = {
"frames": [
{
"filename": "running bot.swf/0000",
"frame": {
"x": 34,
"y": 128,
"w": 56,
"h": 60
},
"rotated": false,
"trimmed": true,
"spriteSourceSize": {
"x": 0,
"y": 2,
"w": 56,
"h": 60
},
"sourceSize": {
"w": 56,
"h": 64
}
},
{
"filename": "running bot.swf/0001",
"frame": {
"x": 54,
"y": 0,
"w": 56,
"h": 58
},
"rotated": false,
"trimmed": true,
"spriteSourceSize": {
"x": 0,
"y": 3,
"w": 56,
"h": 58
},
"sourceSize": {
"w": 56,
"h": 64
}
},
{
"filename": "running bot.swf/0002",
"frame": {
"x": 54,
"y": 58,
"w": 56,
"h": 58
},
"rotated": false,
"trimmed": true,
"spriteSourceSize": {
"x": 0,
"y": 3,
"w": 56,
"h": 58
},
"sourceSize": {
"w": 56,
"h": 64
}
},
{
"filename": "running bot.swf/0003",
"frame": {
"x": 0,
"y": 192,
"w": 34,
"h": 64
},
"rotated": false,
"trimmed": true,
"spriteSourceSize": {
"x": 11,
"y": 0,
"w": 34,
"h": 64
},
"sourceSize": {
"w": 56,
"h": 64
}
},
{
"filename": "running bot.swf/0004",
"frame": {
"x": 0,
"y": 64,
"w": 54,
"h": 64
},
"rotated": false,
"trimmed": true,
"spriteSourceSize": {
"x": 1,
"y": 0,
"w": 54,
"h": 64
},
"sourceSize": {
"w": 56,
"h": 64
}
},
{
"filename": "running bot.swf/0005",
"frame": {
"x": 196,
"y": 0,
"w": 56,
"h": 58
},
"rotated": false,
"trimmed": true,
"spriteSourceSize": {
"x": 0,
"y": 3,
"w": 56,
"h": 58
},
"sourceSize": {
"w": 56,
"h": 64
}
},
{
"filename": "running bot.swf/0006",
"frame": {
"x": 0,
"y": 0,
"w": 54,
"h": 64
},
"rotated": false,
"trimmed": true,
"spriteSourceSize": {
"x": 1,
"y": 0,
"w": 54,
"h": 64
},
"sourceSize": {
"w": 56,
"h": 64
}
},
{
"filename": "running bot.swf/0007",
"frame": {
"x": 140,
"y": 0,
"w": 56,
"h": 58
},
"rotated": false,
"trimmed": true,
"spriteSourceSize": {
"x": 0,
"y": 3,
"w": 56,
"h": 58
},
"sourceSize": {
"w": 56,
"h": 64
}
},
{
"filename": "running bot.swf/0008",
"frame": {
"x": 34,
"y": 188,
"w": 50,
"h": 60
},
"rotated": false,
"trimmed": true,
"spriteSourceSize": {
"x": 3,
"y": 2,
"w": 50,
"h": 60
},
"sourceSize": {
"w": 56,
"h": 64
}
},
{
"filename": "running bot.swf/0009",
"frame": {
"x": 0,
"y": 128,
"w": 34,
"h": 64
},
"rotated": false,
"trimmed": true,
"spriteSourceSize": {
"x": 11,
"y": 0,
"w": 34,
"h": 64
},
"sourceSize": {
"w": 56,
"h": 64
}
},
{
"filename": "running bot.swf/0010",
"frame": {
"x": 84,
"y": 188,
"w": 56,
"h": 58
},
"rotated": false,
"trimmed": true,
"spriteSourceSize": {
"x": 0,
"y": 3,
"w": 56,
"h": 58
},
"sourceSize": {
"w": 56,
"h": 64
}
}
],
"meta": {
"app": "http://www.texturepacker.com",
"version": "1.0",
"image": "running_bot.png",
"format": "RGBA8888",
"size": {
"w": 252,
"h": 256
},
"scale": "0.2",
"smartupdate": "$TexturePacker:SmartUpdate:fb56f261b1eb04e3215824426595f64c$"
}
};
})();
-143
View File
@@ -1,143 +0,0 @@
/// <reference path="../../Phaser/Game.ts" />
(function () {
var myGame = new Phaser.Game(this, 'game', 800, 600, init, create, update);
function init() {
// Texture Atlas Method 1
//
// In this example we assume that the TexturePacker JSON data is a real json object stored as a var
// (in this case botData)
myGame.loader.addTextureAtlas('bot', 'assets/sprites/running_bot.png', null, botData);
myGame.loader.load();
}
var bot: Phaser.Sprite;
function create() {
bot = myGame.add.sprite(myGame.stage.width, 300, 'bot');
bot.animations.add('run');
bot.animations.play('run', 10, true);
bot.velocity.x = -100;
}
function update() {
if (bot.x < -bot.width)
{
bot.x = myGame.stage.width;
}
}
var botData = {
"frames": [
{
"filename": "running bot.swf/0000",
"frame": { "x": 34, "y": 128, "w": 56, "h": 60 },
"rotated": false,
"trimmed": true,
"spriteSourceSize": { "x": 0, "y": 2, "w": 56, "h": 60 },
"sourceSize": { "w": 56, "h": 64 }
},
{
"filename": "running bot.swf/0001",
"frame": { "x": 54, "y": 0, "w": 56, "h": 58 },
"rotated": false,
"trimmed": true,
"spriteSourceSize": { "x": 0, "y": 3, "w": 56, "h": 58 },
"sourceSize": { "w": 56, "h": 64 }
},
{
"filename": "running bot.swf/0002",
"frame": { "x": 54, "y": 58, "w": 56, "h": 58 },
"rotated": false,
"trimmed": true,
"spriteSourceSize": { "x": 0, "y": 3, "w": 56, "h": 58 },
"sourceSize": { "w": 56, "h": 64 }
},
{
"filename": "running bot.swf/0003",
"frame": { "x": 0, "y": 192, "w": 34, "h": 64 },
"rotated": false,
"trimmed": true,
"spriteSourceSize": { "x": 11, "y": 0, "w": 34, "h": 64 },
"sourceSize": { "w": 56, "h": 64 }
},
{
"filename": "running bot.swf/0004",
"frame": { "x": 0, "y": 64, "w": 54, "h": 64 },
"rotated": false,
"trimmed": true,
"spriteSourceSize": { "x": 1, "y": 0, "w": 54, "h": 64 },
"sourceSize": { "w": 56, "h": 64 }
},
{
"filename": "running bot.swf/0005",
"frame": { "x": 196, "y": 0, "w": 56, "h": 58 },
"rotated": false,
"trimmed": true,
"spriteSourceSize": { "x": 0, "y": 3, "w": 56, "h": 58 },
"sourceSize": { "w": 56, "h": 64 }
},
{
"filename": "running bot.swf/0006",
"frame": { "x": 0, "y": 0, "w": 54, "h": 64 },
"rotated": false,
"trimmed": true,
"spriteSourceSize": { "x": 1, "y": 0, "w": 54, "h": 64 },
"sourceSize": { "w": 56, "h": 64 }
},
{
"filename": "running bot.swf/0007",
"frame": { "x": 140, "y": 0, "w": 56, "h": 58 },
"rotated": false,
"trimmed": true,
"spriteSourceSize": { "x": 0, "y": 3, "w": 56, "h": 58 },
"sourceSize": { "w": 56, "h": 64 }
},
{
"filename": "running bot.swf/0008",
"frame": { "x": 34, "y": 188, "w": 50, "h": 60 },
"rotated": false,
"trimmed": true,
"spriteSourceSize": { "x": 3, "y": 2, "w": 50, "h": 60 },
"sourceSize": { "w": 56, "h": 64 }
},
{
"filename": "running bot.swf/0009",
"frame": { "x": 0, "y": 128, "w": 34, "h": 64 },
"rotated": false,
"trimmed": true,
"spriteSourceSize": { "x": 11, "y": 0, "w": 34, "h": 64 },
"sourceSize": { "w": 56, "h": 64 }
},
{
"filename": "running bot.swf/0010",
"frame": { "x": 84, "y": 188, "w": 56, "h": 58 },
"rotated": false,
"trimmed": true,
"spriteSourceSize": { "x": 0, "y": 3, "w": 56, "h": 58 },
"sourceSize": { "w": 56, "h": 64 }
}],
"meta": {
"app": "http://www.texturepacker.com",
"version": "1.0",
"image": "running_bot.png",
"format": "RGBA8888",
"size": { "w": 252, "h": 256 },
"scale": "0.2",
"smartupdate": "$TexturePacker:SmartUpdate:fb56f261b1eb04e3215824426595f64c$"
}
};
})();
-22
View File
@@ -1,22 +0,0 @@
/// <reference path="../../Phaser/Game.ts" />
(function () {
var myGame = new Phaser.Game(this, 'game', 800, 600, init, create);
function init() {
myGame.loader.addImageFile('atari', 'assets/sprites/atari130xe.png');
myGame.loader.load();
}
var atari;
function create() {
atari = myGame.add.sprite(300, 0, 'atari');
startBounceTween();
}
function startBounceTween() {
atari.y = 0;
var bounce = myGame.add.tween(atari);
bounce.to({
y: 500
}, 1000 + Math.random() * 3000, Phaser.Easing.Bounce.Out);
bounce.onComplete.add(startBounceTween, this);
bounce.start();
}
})();
-36
View File
@@ -1,36 +0,0 @@
/// <reference path="../../Phaser/Game.ts" />
(function () {
var myGame = new Phaser.Game(this, 'game', 800, 600, init, create);
function init() {
myGame.loader.addImageFile('atari', 'assets/sprites/atari130xe.png');
myGame.loader.load();
}
var atari: Phaser.Sprite;
function create() {
atari = myGame.add.sprite(300, 0, 'atari');
startBounceTween();
}
function startBounceTween() {
atari.y = 0;
var bounce: Phaser.Tween = myGame.add.tween(atari);
bounce.to({ y: 500 }, 1000 + Math.random() * 3000, Phaser.Easing.Bounce.Out);
bounce.onComplete.add(startBounceTween, this);
bounce.start();
}
})();
-15
View File
@@ -1,15 +0,0 @@
/// <reference path="../../Phaser/Game.ts" />
(function () {
var myGame = new Phaser.Game(this, 'game', 800, 600, init, create);
function init() {
myGame.loader.addImageFile('atari', 'assets/sprites/atari130xe.png');
myGame.loader.load();
}
function create() {
var atari = myGame.add.sprite(300, 0, 'atari');
// Here is the short-hand way of creating a tween, by chaining the call to it:
myGame.add.tween(atari).to({
y: 400
}, 5000, Phaser.Easing.Elastic.Out, true);
}
})();
-24
View File
@@ -1,24 +0,0 @@
/// <reference path="../../Phaser/Game.ts" />
(function () {
var myGame = new Phaser.Game(this, 'game', 800, 600, init, create);
function init() {
myGame.loader.addImageFile('atari', 'assets/sprites/atari130xe.png');
myGame.loader.load();
}
function create() {
var atari = myGame.add.sprite(300, 0, 'atari');
// Here is the short-hand way of creating a tween, by chaining the call to it:
myGame.add.tween(atari).to({ y: 400 }, 5000, Phaser.Easing.Elastic.Out, true);
}
})();