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
+97 -12
View File
@@ -74,10 +74,27 @@
<Content Include="buttons\rotated buttons.js">
<DependentUpon>rotated buttons.ts</DependentUpon>
</Content>
<TypeScriptCompile Include="camera fx\fade.ts" />
<Content Include="camera fx\fade.js">
<DependentUpon>fade.ts</DependentUpon>
</Content>
<TypeScriptCompile Include="camera fx\scanlines.ts" />
<Content Include="camera fx\scanlines.js">
<DependentUpon>scanlines.ts</DependentUpon>
</Content>
<Content Include="cameras\basic camera 1.js">
<DependentUpon>basic camera 1.ts</DependentUpon>
</Content>
<TypeScriptCompile Include="cameras\scrollfactor 1.ts" />
<Content Include="cameras\basic follow.ts" />
<Content Include="cameras\camera fx 1.ts" />
<Content Include="cameras\camera fx 2.ts" />
<Content Include="cameras\camera fx 3.ts" />
<Content Include="cameras\camera scale.ts" />
<Content Include="cameras\camera texture.ts" />
<Content Include="cameras\follow styles.ts" />
<Content Include="cameras\hide from camera.ts" />
<Content Include="cameras\multi camera.ts" />
<Content Include="cameras\scrollfactor 1.js">
<DependentUpon>scrollfactor 1.ts</DependentUpon>
</Content>
@@ -89,21 +106,43 @@
<TypeScriptCompile Include="input\over sprite 1.ts" />
<TypeScriptCompile Include="groups\create group 1.ts" />
<TypeScriptCompile Include="cameras\world sprite.ts" />
<Content Include="cameras\scrollfactor compare.ts" />
<Content Include="cameras\world sprite.js">
<DependentUpon>world sprite.ts</DependentUpon>
</Content>
<TypeScriptCompile Include="groups\bring to top 1.ts" />
<Content Include="groups\add to group 1.ts" />
<Content Include="groups\add to group 2.ts" />
<Content Include="groups\bring to top 1.js">
<DependentUpon>bring to top 1.ts</DependentUpon>
</Content>
<Content Include="groups\bring to top.ts" />
<Content Include="groups\call all.ts" />
<Content Include="groups\create group 1.js">
<DependentUpon>create group 1.ts</DependentUpon>
</Content>
<TypeScriptCompile Include="groups\display order.ts" />
<Content Include="groups\direct render.ts" />
<Content Include="groups\display order.js">
<DependentUpon>display order.ts</DependentUpon>
</Content>
<TypeScriptCompile Include="groups\swap children.ts" />
<Content Include="groups\for each.ts" />
<Content Include="groups\get first 1.ts" />
<Content Include="groups\get first 2.ts" />
<Content Include="groups\get first 3.ts" />
<Content Include="groups\group as layer.ts" />
<Content Include="groups\group transform 1.ts" />
<Content Include="groups\group transform 2.ts" />
<Content Include="groups\group transform 3.ts" />
<Content Include="groups\recycle 1.ts" />
<Content Include="groups\recycle 2.ts" />
<Content Include="groups\remove.ts" />
<Content Include="groups\replace.ts" />
<Content Include="groups\set all.ts" />
<Content Include="groups\sort 1.ts" />
<Content Include="groups\sort 2.ts" />
<Content Include="groups\sub groups.ts" />
<Content Include="groups\swap children.js">
<DependentUpon>swap children.ts</DependentUpon>
</Content>
@@ -122,9 +161,12 @@
<TypeScriptCompile Include="input\motion lock.ts" />
<TypeScriptCompile Include="input\motion lock 2.ts" />
<TypeScriptCompile Include="input\game scale 1.ts" />
<Content Include="input\drop limitation.ts" />
<Content Include="input\game scale 1.js">
<DependentUpon>game scale 1.ts</DependentUpon>
</Content>
<Content Include="input\keyboard 1.ts" />
<Content Include="input\keyboard 2.ts" />
<Content Include="input\motion lock 2.js">
<DependentUpon>motion lock 2.ts</DependentUpon>
</Content>
@@ -164,6 +206,12 @@
</Content>
<TypeScriptCompile Include="mobile\sprite test 1.ts" />
<TypeScriptCompile Include="misc\point1.ts" />
<Content Include="misc\color utils 1.ts" />
<Content Include="misc\color utils 2.ts" />
<Content Include="misc\color utils 3.ts" />
<Content Include="misc\dynamic texture 1.ts" />
<Content Include="misc\dynamic texture 2.ts" />
<Content Include="misc\dynamic texture 3.ts" />
<Content Include="misc\point1.js">
<DependentUpon>point1.ts</DependentUpon>
</Content>
@@ -175,6 +223,8 @@
<Content Include="misc\point3.js">
<DependentUpon>point3.ts</DependentUpon>
</Content>
<Content Include="misc\rectangle utils 1.ts" />
<Content Include="misc\rectangle utils 2.ts" />
<Content Include="mobile\sprite test 1.js">
<DependentUpon>sprite test 1.ts</DependentUpon>
</Content>
@@ -202,10 +252,6 @@
<TypeScriptCompile Include="scrollzones\region demo.ts" />
<TypeScriptCompile Include="scrollzones\parallax.ts" />
<TypeScriptCompile Include="scrollzones\ballscroller.ts" />
<TypeScriptCompile Include="physics\simple test 1.ts" />
<Content Include="physics\simple test 1.js">
<DependentUpon>simple test 1.ts</DependentUpon>
</Content>
<Content Include="scrollzones\ballscroller.js">
<DependentUpon>ballscroller.ts</DependentUpon>
</Content>
@@ -229,17 +275,13 @@
<Content Include="scrollzones\skewed scroller.js">
<DependentUpon>skewed scroller.ts</DependentUpon>
</Content>
<TypeScriptCompile Include="sprites\atlas 1.ts" />
<TypeScriptCompile Include="sprites\alpha.ts" />
<Content Include="sprites\alpha.js">
<DependentUpon>alpha.ts</DependentUpon>
</Content>
<Content Include="sprites\atlas 1.js">
<DependentUpon>atlas 1.ts</DependentUpon>
</Content>
<TypeScriptCompile Include="sprites\atlas 2.ts" />
<Content Include="sprites\atlas 2.js">
<DependentUpon>atlas 2.ts</DependentUpon>
<TypeScriptCompile Include="sprites\animate by framename.ts" />
<Content Include="sprites\animate by framename.js">
<DependentUpon>animate by framename.ts</DependentUpon>
</Content>
<TypeScriptCompile Include="sprites\origin 5.ts" />
<Content Include="sprites\origin 5.js">
@@ -247,6 +289,8 @@
</Content>
<TypeScriptCompile Include="tilemaps\csv tilemap.ts" />
<TypeScriptCompile Include="stage\blur filter.ts" />
<Content Include="sprites\out of screen.ts" />
<Content Include="sprites\rotate around.ts" />
<Content Include="stage\blur filter.js">
<DependentUpon>blur filter.ts</DependentUpon>
</Content>
@@ -271,9 +315,37 @@
<DependentUpon>sepia filter.ts</DependentUpon>
</Content>
<TypeScriptCompile Include="textures\filter test.ts" />
<TypeScriptCompile Include="textures\dynamic texture 1.ts" />
<Content Include="textures\dynamic texture 1.js">
<DependentUpon>dynamic texture 1.ts</DependentUpon>
</Content>
<TypeScriptCompile Include="textures\dynamic texture 2.ts" />
<Content Include="textures\dynamic texture 2.js">
<DependentUpon>dynamic texture 2.ts</DependentUpon>
</Content>
<Content Include="textures\filter test.js">
<DependentUpon>filter test.ts</DependentUpon>
</Content>
<TypeScriptCompile Include="textures\starling texture atlas.ts" />
<Content Include="textures\starling texture atlas.js">
<DependentUpon>starling texture atlas.ts</DependentUpon>
</Content>
<TypeScriptCompile Include="textures\texture atlas 1.ts" />
<Content Include="textures\texture atlas 1.js">
<DependentUpon>texture atlas 1.ts</DependentUpon>
</Content>
<TypeScriptCompile Include="textures\texture atlas 2.ts" />
<Content Include="textures\texture atlas 2.js">
<DependentUpon>texture atlas 2.ts</DependentUpon>
</Content>
<TypeScriptCompile Include="textures\texture atlas 3.ts" />
<Content Include="textures\texture atlas 3.js">
<DependentUpon>texture atlas 3.ts</DependentUpon>
</Content>
<TypeScriptCompile Include="textures\texture atlas 4.ts" />
<Content Include="textures\texture atlas 4.js">
<DependentUpon>texture atlas 4.ts</DependentUpon>
</Content>
<Content Include="tilemaps\csv tilemap.js">
<DependentUpon>csv tilemap.ts</DependentUpon>
</Content>
@@ -289,6 +361,16 @@
<Content Include="tilemaps\tiled tilemap.js">
<DependentUpon>tiled tilemap.ts</DependentUpon>
</Content>
<TypeScriptCompile Include="tweens\bounce.ts" />
<Content Include="tweens\bounce.js">
<DependentUpon>bounce.ts</DependentUpon>
</Content>
<Content Include="tweens\easing example 1.ts" />
<Content Include="tweens\easing example 2.ts" />
<Content Include="tweens\easing example 3.ts" />
<Content Include="tweens\easing example 4.ts" />
<Content Include="tweens\easing example 5.ts" />
<Content Include="tweens\easing example 6.ts" />
<Content Include="tweens\tween loop 1.js">
<DependentUpon>tween loop 1.ts</DependentUpon>
</Content>
@@ -350,6 +432,9 @@
<DependentUpon>boot screen.ts</DependentUpon>
</Content>
</ItemGroup>
<ItemGroup />
<ItemGroup>
<Folder Include="animation\" />
<Folder Include="physics\" />
</ItemGroup>
<Import Project="$(VSToolsPath)\TypeScript\Microsoft.TypeScript.targets" />
</Project>
View File
View File
+32
View File
@@ -0,0 +1,32 @@
/// <reference path="../../Phaser/Game.ts" />
/// <reference path="../../build/phaser-fx.d.ts" />
(function () {
var game = new Phaser.Game(this, 'game', 800, 600, init, create, update);
function init() {
game.load.image('backdrop', 'assets/pics/ninja-masters2.png');
game.load.start();
}
var scanlines;
function create() {
game.world.setSize(1216, 896);
// Add our effect to the camera
scanlines = game.camera.fx.add(Phaser.FX.Camera.Scanlines);
// We'll have the scanlines spaced out every 2 pixels
scanlines.spacing = 2;
// This is the color the lines will be drawn in
scanlines.color = 'rgba(0, 0, 0, 0.8)';
game.add.sprite(0, 0, 'backdrop');
}
function update() {
if(game.input.keyboard.isDown(Phaser.Keyboard.LEFT)) {
game.camera.x -= 4;
} else if(game.input.keyboard.isDown(Phaser.Keyboard.RIGHT)) {
game.camera.x += 4;
}
if(game.input.keyboard.isDown(Phaser.Keyboard.UP)) {
game.camera.y -= 4;
} else if(game.input.keyboard.isDown(Phaser.Keyboard.DOWN)) {
game.camera.y += 4;
}
}
})();
+57
View File
@@ -0,0 +1,57 @@
/// <reference path="../../Phaser/Game.ts" />
/// <reference path="../../build/phaser-fx.d.ts" />
(function () {
var game = new Phaser.Game(this, 'game', 800, 600, init, create, update);
function init() {
game.load.image('backdrop', 'assets/pics/ninja-masters2.png');
game.load.start();
}
var scanlines: Phaser.FX.Camera.Scanlines;
function create() {
game.world.setSize(1216, 896);
// Add our effect to the camera
scanlines = <Phaser.FX.Camera.Scanlines> game.camera.fx.add(Phaser.FX.Camera.Scanlines);
// We'll have the scanlines spaced out every 2 pixels
scanlines.spacing = 2;
// This is the color the lines will be drawn in
scanlines.color = 'rgba(0, 0, 0, 0.8)';
game.add.sprite(0, 0, 'backdrop');
}
function update() {
if (game.input.keyboard.isDown(Phaser.Keyboard.LEFT))
{
game.camera.x -= 4;
}
else if (game.input.keyboard.isDown(Phaser.Keyboard.RIGHT))
{
game.camera.x += 4;
}
if (game.input.keyboard.isDown(Phaser.Keyboard.UP))
{
game.camera.y -= 4;
}
else if (game.input.keyboard.isDown(Phaser.Keyboard.DOWN))
{
game.camera.y += 4;
}
}
})();
+2
View File
@@ -1,3 +1,5 @@
/// <reference path="../../Phaser/Game.ts" />
(function() {
var game = new Phaser.Game(this, 'game', 800, 600, null, create, null, render);
+47 -24
View File
@@ -274,7 +274,7 @@ var Phaser;
get: /**
* Determines whether or not this Rectangle object is empty.
* @method isEmpty
* @return {Boolean} A value of true if the Rectangle object's width or height is less than or equal to 0; otherwise false.
* @return {Boolean} A value of true if the Rectangle objects width or height is less than or equal to 0; otherwise false.
**/
function () {
return (!this.width || !this.height);
@@ -2139,6 +2139,10 @@ var Phaser;
this.context.putImageData(sourceTexture.getPixels(sourceRect), destPoint.x, destPoint.y);
}
};
DynamicTexture.prototype.add = function (sprite) {
sprite.texture.canvas = this.canvas;
sprite.texture.context = this.context;
};
DynamicTexture.prototype.assignCanvasToGameObjects = /**
* Given an array of Sprites it will update each of them so that their canvas/contexts reference this DynamicTexture
* @param objects {Array} An array of GameObjects, or objects that inherit from it such as Sprites
@@ -2834,11 +2838,13 @@ var Phaser;
return this.currentFrame.name;
},
set: function (value) {
if(this._frameData.getFrameByName(value)) {
if(this._frameData && this._frameData.getFrameByName(value)) {
this.currentFrame = this._frameData.getFrameByName(value);
this._parent.texture.width = this.currentFrame.width;
this._parent.texture.height = this.currentFrame.height;
this._frameIndex = this.currentFrame.index;
} else {
throw new Error("Cannot set frameName: " + value);
}
},
enumerable: true,
@@ -3652,6 +3658,7 @@ var Phaser;
this._pointerData[pointer.id].isDown = true;
this._pointerData[pointer.id].isUp = false;
this._pointerData[pointer.id].timeDown = this.game.time.now;
//console.log('touchedHandler: ' + Date.now());
this._parent.events.onInputDown.dispatch(this._parent, pointer);
// Start drag
//if (this.draggable && this.isDragged == false && pointer.targetObject == null)
@@ -3675,6 +3682,7 @@ var Phaser;
this._pointerData[pointer.id].downDuration = this._pointerData[pointer.id].timeUp - this._pointerData[pointer.id].timeDown;
// Only release the InputUp signal if the pointer is still over this sprite
if(Phaser.SpriteUtils.overlapsXY(this._parent, pointer.worldX(), pointer.worldY())) {
//console.log('releasedHandler: ' + Date.now());
this._parent.events.onInputUp.dispatch(this._parent, pointer);
} else {
// Pointer outside the sprite? Reset the cursor
@@ -7844,6 +7852,7 @@ var Phaser;
function (key) {
this._fileList[key].loaded = true;
this._fileList[key].error = true;
throw new Error("Phaser.Loader error loading file: " + key);
this.nextFile(key, false);
};
Loader.prototype.fileComplete = /**
@@ -7929,6 +7938,7 @@ var Phaser;
function (key) {
var file = this._fileList[key];
file.error = true;
throw new Error("Phaser.Loader dataLoadError: " + key);
this.nextFile(key, true);
};
Loader.prototype.xmlLoadComplete = function (key) {
@@ -11322,6 +11332,7 @@ var Phaser;
}
};
Button.prototype.onInputDownHandler = function (pointer) {
//console.log('Button onInputDownHandler: ' + Date.now());
if(this._onDownFrameName != null) {
this.frameName = this._onDownFrameName;
} else if(this._onDownFrameID != null) {
@@ -11332,6 +11343,7 @@ var Phaser;
}
};
Button.prototype.onInputUpHandler = function (pointer) {
//console.log('Button onInputUpHandler: ' + Date.now());
if(this._onUpFrameName != null) {
this.frameName = this._onUpFrameName;
} else if(this._onUpFrameID != null) {
@@ -16323,6 +16335,10 @@ var Phaser;
*/
function () {
var _this = this;
if(this._game.device.android && this._game.device.chrome == false) {
// Android stock browser fires mouse events even if you preventDefault on the touchStart, so ...
return;
}
this._game.stage.canvas.addEventListener('mousedown', function (event) {
return _this.onMouseDown(event);
}, true);
@@ -17846,9 +17862,6 @@ var Phaser;
if(sprite.transform.scale.x == 0 || sprite.transform.scale.y == 0 || sprite.texture.alpha < 0.1 || this.inCamera(camera, sprite) == false) {
return false;
}
if(sprite.crop && sprite.crop.empty) {
return;
}
sprite.renderOrderID = this._count;
this._count++;
// Reset our temp vars
@@ -17861,16 +17874,6 @@ var Phaser;
this._dy = camera.screenView.y + sprite.y - (camera.worldView.y * sprite.transform.scrollFactor.y);
this._dw = sprite.texture.width;
this._dh = sprite.texture.height;
// Global Composite Ops
if(sprite.texture.globalCompositeOperation) {
sprite.texture.context.save();
sprite.texture.context.globalCompositeOperation = sprite.texture.globalCompositeOperation;
}
// Alpha
if(sprite.texture.alpha !== 1 && sprite.texture.context.globalAlpha != sprite.texture.alpha) {
this._ga = sprite.texture.context.globalAlpha;
sprite.texture.context.globalAlpha = sprite.texture.alpha;
}
if(sprite.animations.currentFrame !== null) {
this._sx = sprite.animations.currentFrame.x;
this._sy = sprite.animations.currentFrame.y;
@@ -17907,15 +17910,36 @@ var Phaser;
this._dy += sprite.crop.y * sprite.transform.scale.y;
this._dw = sprite.crop.width * sprite.transform.scale.x;
this._dh = sprite.crop.height * sprite.transform.scale.y;
//this._sx += sprite.crop.x;
//this._sy += sprite.crop.y;
//this._sw = sprite.crop.width;
//this._sh = sprite.crop.height;
//this._dx += sprite.crop.x;
//this._dy += sprite.crop.y;
//this._dw = sprite.crop.width;
//this._dh = sprite.crop.height;
}
this._sx = Math.floor(this._sx);
this._sy = Math.floor(this._sy);
this._sw = Math.floor(this._sw);
this._sh = Math.floor(this._sh);
this._dx = Math.floor(this._dx);
this._dy = Math.floor(this._dy);
this._dw = Math.floor(this._dw);
this._dh = Math.floor(this._dh);
if(this._sw <= 0 || this._sh <= 0 || this._dw <= 0 || this._dh <= 0) {
return false;
}
// Global Composite Ops
if(sprite.texture.globalCompositeOperation) {
sprite.texture.context.save();
sprite.texture.context.globalCompositeOperation = sprite.texture.globalCompositeOperation;
}
// Alpha
if(sprite.texture.alpha !== 1 && sprite.texture.context.globalAlpha != sprite.texture.alpha) {
this._ga = sprite.texture.context.globalAlpha;
sprite.texture.context.globalAlpha = sprite.texture.alpha;
}
this._sx = Math.round(this._sx);
this._sy = Math.round(this._sy);
this._sw = Math.round(this._sw);
this._sh = Math.round(this._sh);
this._dx = Math.round(this._dx);
this._dy = Math.round(this._dy);
this._dw = Math.round(this._dw);
this._dh = Math.round(this._dh);
if(sprite.texture.opaque) {
sprite.texture.context.fillStyle = sprite.texture.backgroundColor;
sprite.texture.context.fillRect(this._dx, this._dy, this._dw, this._dh);
@@ -19622,7 +19646,6 @@ var Phaser;
this.input = game.input;
this.load = game.load;
this.math = game.math;
//this.motion = game.motion;
this.sound = game.sound;
this.stage = game.stage;
this.time = game.time;
-45
View File
@@ -1,45 +0,0 @@
/// <reference path="../../Phaser/Game.ts" />
(function () {
var game = new Phaser.Game(this, 'game', 800, 600, init, create, null, render);
function init() {
// Using Phasers asset loader we load up a PNG from the assets folder
game.load.image('atari', 'assets/sprites/atari130xe.png');
game.load.image('ball', 'assets/sprites/shinyball.png');
game.load.start();
}
var atari;
var ball;
function create() {
// Add some gravity to the world, otherwise nothing will actually happen
game.physics.gravity.setTo(0, 5);
// We'll make the atari sprite a static body, so it won't be influenced by gravity or other forces
atari = game.add.physicsSprite(300, 450, 'atari', null, Phaser.Types.BODY_STATIC);
//atari.rotation = 10;
//atari.body.transform.setRotation(1);
//atari.body.angle = 1;
atari.body.setTransform(atari.body.position, 1);
atari.body.syncTransform();
// atari = 220px width (110 = center x)
// ball = 32px width (16 = center x)
// Ball will be a dynamic body and fall based on gravity
ball = game.add.physicsSprite(300 - 20, 0, 'ball');
//ball.body.angle = 1;
//ball.body.transform.setRotation(1);
//ball.body.fixedRotation = true;
// limit the velocity or things can go nuts
ball.body.linearDamping = 0.5;
ball.body.angularDamping = 0.5;
// when the ball bounces out of the game world, call the resetBall function
ball.outOfBoundsAction = Phaser.Types.OUT_OF_BOUNDS_PERSIST;
ball.events.onOutOfBounds.add(resetBall, this);
}
function resetBall() {
ball.body.setPosition(300, 0);
}
function render() {
Phaser.DebugUtils.renderPhysicsBodyInfo(atari.body, 32, 32);
Phaser.DebugUtils.renderPhysicsBodyInfo(ball.body, 320, 32);
Phaser.DebugUtils.renderPhysicsBody(atari.body);
Phaser.DebugUtils.renderPhysicsBody(ball.body);
}
})();
-65
View File
@@ -1,65 +0,0 @@
/// <reference path="../../Phaser/Game.ts" />
(function () {
var game = new Phaser.Game(this, 'game', 800, 600, init, create, null, render);
function init() {
// Using Phasers asset loader we load up a PNG from the assets folder
game.load.image('atari', 'assets/sprites/atari130xe.png');
game.load.image('ball', 'assets/sprites/shinyball.png');
game.load.start();
}
var atari: Phaser.Sprite;
var ball: Phaser.Sprite;
function create() {
// Add some gravity to the world, otherwise nothing will actually happen
game.physics.gravity.setTo(0, 5);
// We'll make the atari sprite a static body, so it won't be influenced by gravity or other forces
atari = game.add.physicsSprite(300, 450, 'atari', null, Phaser.Types.BODY_STATIC);
//atari.rotation = 10;
//atari.body.transform.setRotation(1);
//atari.body.angle = 1;
atari.body.setTransform(atari.body.position, 1);
atari.body.syncTransform();
// atari = 220px width (110 = center x)
// ball = 32px width (16 = center x)
// Ball will be a dynamic body and fall based on gravity
ball = game.add.physicsSprite(300-20, 0, 'ball');
//ball.body.angle = 1;
//ball.body.transform.setRotation(1);
//ball.body.fixedRotation = true;
// limit the velocity or things can go nuts
ball.body.linearDamping = 0.5;
ball.body.angularDamping = 0.5;
// when the ball bounces out of the game world, call the resetBall function
ball.outOfBoundsAction = Phaser.Types.OUT_OF_BOUNDS_PERSIST;
ball.events.onOutOfBounds.add(resetBall, this);
}
function resetBall() {
ball.body.setPosition(300, 0);
}
function render() {
Phaser.DebugUtils.renderPhysicsBodyInfo(atari.body, 32, 32);
Phaser.DebugUtils.renderPhysicsBodyInfo(ball.body, 320, 32);
Phaser.DebugUtils.renderPhysicsBody(atari.body);
Phaser.DebugUtils.renderPhysicsBody(ball.body);
}
})();
+6 -2
View File
@@ -62,7 +62,7 @@
speed = 0;
}
}
shipMotion = game.motion.velocityFromAngle(ship.rotation, speed);
//shipMotion = game.motion.velocityFromAngle(ship.rotation, speed);
scroller.setSpeed(shipMotion.x, shipMotion.y);
// emit particles
if(speed > 2) {
@@ -89,7 +89,11 @@
var b = bullets.getFirstAvailable();
b.x = ship.x;
b.y = ship.y - 26;
var bulletMotion = game.motion.velocityFromAngle(ship.rotation, 400);
//var bulletMotion = game.motion.velocityFromAngle(ship.rotation, 400);
var bulletMotion = {
x: 0,
y: 0
};
b.revive();
b.rotation = ship.rotation;
b.body.velocity.setTo(bulletMotion.x, bulletMotion.y);
+3 -2
View File
@@ -99,7 +99,7 @@
}
}
shipMotion = game.motion.velocityFromAngle(ship.rotation, speed);
//shipMotion = game.motion.velocityFromAngle(ship.rotation, speed);
scroller.setSpeed(shipMotion.x, shipMotion.y);
@@ -144,7 +144,8 @@
b.x = ship.x;
b.y = ship.y - 26;
var bulletMotion = game.motion.velocityFromAngle(ship.rotation, 400);
//var bulletMotion = game.motion.velocityFromAngle(ship.rotation, 400);
var bulletMotion = {x:0,y:0};
b.revive();
b.rotation = ship.rotation;
+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);
function init() {
game.load.atlas('bot', 'assets/sprites/running_bot.png', 'assets/sprites/running_bot.json');
game.load.start();
}
var bot;
function create() {
bot = game.add.sprite(game.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() {
bot.x -= 1;
if(bot.x < -bot.width) {
bot.x = game.stage.width;
}
}
})();
+42
View File
@@ -0,0 +1,42 @@
/// <reference path="../../Phaser/Game.ts" />
(function () {
var game = new Phaser.Game(this, 'game', 800, 600, init, create, update);
function init() {
game.load.atlas('bot', 'assets/sprites/running_bot.png', 'assets/sprites/running_bot.json');
game.load.start();
}
var bot: Phaser.Sprite;
function create() {
bot = game.add.sprite(game.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() {
bot.x -= 1;
if (bot.x < -bot.width)
{
bot.x = game.stage.width;
}
}
})();
-17
View File
@@ -1,17 +0,0 @@
/// <reference path="../../Phaser/Game.ts" />
(function () {
var game = new Phaser.Game(this, 'game', 800, 600, init, create);
function init() {
game.load.atlas('atlas', 'assets/sprites/invaderpig.png', 'assets/sprites/invaderpig.json');
game.load.start();
}
var pig;
var invader;
function create() {
game.stage.backgroundColor = 'rgb(40, 40, 40)';
pig = game.add.sprite(200, 200, 'atlas', 'tennyson');
invader = game.add.sprite(0, 0, 'atlas', 'invader1');
console.log(pig.width, pig.height, pig.body.bounds.width, pig.body.bounds.height, pig.worldView);
console.log(invader.width, invader.height, invader.body.bounds.width, invader.body.bounds.height, invader.worldView);
}
})();
-29
View File
@@ -1,29 +0,0 @@
/// <reference path="../../Phaser/Game.ts" />
(function () {
var game = new Phaser.Game(this, 'game', 800, 600, init, create);
function init() {
game.load.atlas('atlas', 'assets/sprites/invaderpig.png', 'assets/sprites/invaderpig.json');
game.load.start();
}
var pig: Phaser.Sprite;
var invader: Phaser.Sprite;
function create() {
game.stage.backgroundColor = 'rgb(40, 40, 40)';
pig = game.add.sprite(200, 200, 'atlas', 'tennyson');
invader = game.add.sprite(0, 0, 'atlas', 'invader1');
console.log(pig.width, pig.height, pig.body.bounds.width, pig.body.bounds.height, pig.worldView);
console.log(invader.width, invader.height, invader.body.bounds.width, invader.body.bounds.height, invader.worldView);
}
})();
+1 -1
View File
@@ -13,7 +13,7 @@
// Here we'll assign the new sprite to the local fuji variable
fuji = game.add.sprite(game.stage.centerX, game.stage.centerY, 'fuji');
// sets origin to the center of the sprite (half the width and half the height)
fuji.transform.origin.setTo(160, 100);
fuji.transform.origin.setTo(0.5, 0.5);
// We'll tween the scale down to zero (which will make the sprite invisible) and then flip it
// The end result should look like turning over a card
// Create our tween
+1 -1
View File
@@ -23,7 +23,7 @@
fuji = game.add.sprite(game.stage.centerX, game.stage.centerY, 'fuji');
// sets origin to the center of the sprite (half the width and half the height)
fuji.transform.origin.setTo(160, 100);
fuji.transform.origin.setTo(0.5, 0.5);
// We'll tween the scale down to zero (which will make the sprite invisible) and then flip it
// The end result should look like turning over a card
+1 -1
View File
@@ -14,7 +14,7 @@
// The sprite is 320 x 200 pixels in size
// Here we set the origin to the center of the sprite (half of its width and height, so 160x100)
// This will cause it to rotate on its center
fuji.transform.origin.setTo(160, 100);
fuji.transform.origin.setTo(0.5, 0.5);
game.add.tween(fuji).to({
rotation: 360
}, 2000, Phaser.Easing.Linear.None, true, 0, true);
+1 -1
View File
@@ -24,7 +24,7 @@
// The sprite is 320 x 200 pixels in size
// Here we set the origin to the center of the sprite (half of its width and height, so 160x100)
// This will cause it to rotate on its center
fuji.transform.origin.setTo(160, 100);
fuji.transform.origin.setTo(0.5, 0.5);
game.add.tween(fuji).to({ rotation: 360 }, 2000, Phaser.Easing.Linear.None, true, 0, true);
+1 -1
View File
@@ -14,7 +14,7 @@
fuji = game.add.sprite(game.stage.centerX, game.stage.centerY, 'fuji');
// The sprite is 320 x 200 pixels in size
// Here we set the origin to be the bottom-right of the sprite
fuji.origin.setTo(320, 200);
fuji.origin.setTo(1, 1);
game.add.tween(fuji).to({
rotation: 360
}, 2000, Phaser.Easing.Linear.None, true, 0, true);
+1 -1
View File
@@ -24,7 +24,7 @@
// The sprite is 320 x 200 pixels in size
// Here we set the origin to be the bottom-right of the sprite
fuji.origin.setTo(320, 200);
fuji.origin.setTo(1, 1);
game.add.tween(fuji).to({ rotation: 360 }, 2000, Phaser.Easing.Linear.None, true, 0, true);
+1 -1
View File
@@ -15,7 +15,7 @@
fuji = game.add.sprite(game.stage.centerX, game.stage.centerY, 'fuji');
// The sprite is 320 x 200 pixels in size
// Here we set the origin to the center of the sprite again, so we can rotate and scale it at the same time
fuji.transform.origin.setTo(160, 100);
fuji.transform.origin.setTo(0.5, 0.5);
game.add.tween(fuji).to({
rotation: 360
}, 2000, Phaser.Easing.Linear.None, true, 0, true);
+1 -1
View File
@@ -25,7 +25,7 @@
// The sprite is 320 x 200 pixels in size
// Here we set the origin to the center of the sprite again, so we can rotate and scale it at the same time
fuji.transform.origin.setTo(160, 100);
fuji.transform.origin.setTo(0.5, 0.5);
game.add.tween(fuji).to({ rotation: 360 }, 2000, Phaser.Easing.Linear.None, true, 0, true);
+57
View File
@@ -0,0 +1,57 @@
/// <reference path="../../Phaser/Game.ts" />
(function () {
var game = new Phaser.Game(this, 'game', 800, 600, init, create, update);
function init() {
game.load.image('ball', 'assets/sprites/shinyball.png');
game.load.start();
}
var wobblyBall;
function create() {
// Create our DynamicTexture
wobblyBall = game.add.dynamicTexture(32, 64);
// And apply it to 100 randomly positioned sprites
for(var i = 0; i < 100; i++) {
var temp = game.add.sprite(game.world.randomX, game.world.randomY);
temp.texture.loadDynamicTexture(wobblyBall);
}
// Populate the wave with some data
waveData = game.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(game.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;
}
}
})();
+80
View File
@@ -0,0 +1,80 @@
/// <reference path="../../Phaser/Game.ts" />
(function () {
var game = new Phaser.Game(this, 'game', 800, 600, init, create, update);
function init() {
game.load.image('ball', 'assets/sprites/shinyball.png');
game.load.start();
}
var wobblyBall: Phaser.DynamicTexture;
function create() {
// Create our DynamicTexture
wobblyBall = game.add.dynamicTexture(32, 64);
// And apply it to 100 randomly positioned sprites
for (var i = 0; i < 100; i++)
{
var temp = game.add.sprite(game.world.randomX, game.world.randomY);
temp.texture.loadDynamicTexture(wobblyBall);
}
// Populate the wave with some data
waveData = game.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(game.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;
}
}
})();
+42
View File
@@ -0,0 +1,42 @@
/// <reference path="../../Phaser/Game.ts" />
(function () {
var game = 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 = game.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 + game.input.x;
//var y: number = yyy + game.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();
}
})();
+66
View File
@@ -0,0 +1,66 @@
/// <reference path="../../Phaser/Game.ts" />
(function () {
var game = 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 = game.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 + game.input.x;
//var y: number = yyy + game.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();
}
})();
+31
View File
@@ -0,0 +1,31 @@
/// <reference path="../../Phaser/Game.ts" />
(function () {
var game = 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
game.load.atlas('bits', 'assets/sprites/shoebox.png', 'assets/sprites/shoebox.xml', null, Phaser.Loader.TEXTURE_ATLAS_XML_STARLING);
game.load.atlas('bot', 'assets/sprites/shoebot.png', 'assets/sprites/shoebot.xml', null, Phaser.Loader.TEXTURE_ATLAS_XML_STARLING);
game.load.start();
}
var bits;
var bot;
function create() {
bot = game.add.sprite(800, 200, 'bot');
bot.animations.add('run');
bot.animations.play('run', 20, true);
bits = game.add.sprite(200, 200, 'bits');
bits.frame = 0;
}
function update() {
bot.x -= 5;
if(bot.x < -bot.width) {
bot.x = game.stage.width;
bits.frame++;
if(bits.frame == bits.animations.frameTotal - 1) {
bits.frame = 0;
}
}
}
})();
+51
View File
@@ -0,0 +1,51 @@
/// <reference path="../../Phaser/Game.ts" />
(function () {
var game = 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
game.load.atlas('bits', 'assets/sprites/shoebox.png', 'assets/sprites/shoebox.xml', null, Phaser.Loader.TEXTURE_ATLAS_XML_STARLING);
game.load.atlas('bot', 'assets/sprites/shoebot.png', 'assets/sprites/shoebot.xml', null, Phaser.Loader.TEXTURE_ATLAS_XML_STARLING);
game.load.start();
}
var bits: Phaser.Sprite;
var bot: Phaser.Sprite;
function create() {
bot = game.add.sprite(800, 200, 'bot');
bot.animations.add('run');
bot.animations.play('run', 20, true);
bits = game.add.sprite(200, 200, 'bits');
bits.frame = 0;
}
function update() {
bot.x -= 5;
if (bot.x < -bot.width)
{
bot.x = game.stage.width;
bits.frame++;
if (bits.frame == bits.animations.frameTotal - 1)
{
bits.frame = 0;
}
}
}
})();
@@ -2,7 +2,7 @@
(function () {
var game = new Phaser.Game(this, 'game', 800, 600, init, create);
function init() {
// Texture Atlas Method 2
// Texture Atlas Method 1
//
// In this example we assume that the TexturePacker JSON data is a string of json data stored as a var
// (in this case botData)
@@ -6,7 +6,7 @@
function init() {
// Texture Atlas Method 2
// Texture Atlas Method 1
//
// In this example we assume that the TexturePacker JSON data is a string of json data stored as a var
// (in this case botData)
+271
View File
@@ -0,0 +1,271 @@
/// <reference path="../../Phaser/Game.ts" />
(function () {
var game = 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 real json object stored as a var
// (in this case botData)
game.load.atlas('bot', 'assets/sprites/running_bot.png', null, botData);
game.load.start();
}
var bot;
function create() {
bot = game.add.sprite(game.stage.width, 300, 'bot');
bot.animations.add('run');
bot.animations.play('run', 10, true);
}
function update() {
bot.x -= 2;
if(bot.x < -bot.width) {
bot.x = game.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
@@ -0,0 +1,143 @@
/// <reference path="../../Phaser/Game.ts" />
(function () {
var game = 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 real json object stored as a var
// (in this case botData)
game.load.atlas('bot', 'assets/sprites/running_bot.png', null, botData);
game.load.start();
}
var bot: Phaser.Sprite;
function create() {
bot = game.add.sprite(game.stage.width, 300, 'bot');
bot.animations.add('run');
bot.animations.play('run', 10, true);
}
function update() {
bot.x -= 2;
if (bot.x < -bot.width)
{
bot.x = game.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$"
}
};
})();
+23
View File
@@ -0,0 +1,23 @@
/// <reference path="../../Phaser/Game.ts" />
(function () {
var game = 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
game.load.atlas('bot', 'assets/sprites/running_bot.png', 'assets/sprites/running_bot.json');
game.load.start();
}
var bot;
function create() {
bot = game.add.sprite(game.stage.width, 300, 'bot');
bot.animations.add('run');
bot.animations.play('run', 10, true);
}
function update() {
bot.x -= 2;
if(bot.x < -bot.width) {
bot.x = game.stage.width;
}
}
})();
+40
View File
@@ -0,0 +1,40 @@
/// <reference path="../../Phaser/Game.ts" />
(function () {
var game = 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
game.load.atlas('bot', 'assets/sprites/running_bot.png', 'assets/sprites/running_bot.json');
game.load.start();
}
var bot: Phaser.Sprite;
function create() {
bot = game.add.sprite(game.stage.width, 300, 'bot');
bot.animations.add('run');
bot.animations.play('run', 10, true);
}
function update() {
bot.x -= 2;
if (bot.x < -bot.width)
{
bot.x = game.stage.width;
}
}
})();
+32
View File
@@ -0,0 +1,32 @@
/// <reference path="../../Phaser/Game.ts" />
(function () {
var game = 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
game.load.atlas('atlas', 'assets/pics/texturepacker_test.png', 'assets/pics/texturepacker_test.json');
game.load.start();
}
var chick;
var car;
var mech;
var robot;
var cop;
function create() {
game.stage.backgroundColor = 'rgb(40, 40, 40)';
chick = game.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 = game.add.sprite(600, 64, 'atlas');
cop.frameName = 'ladycop.png';
robot = game.add.sprite(50, 300, 'atlas');
robot.frameName = 'robot.png';
car = game.add.sprite(100, 400, 'atlas');
car.frameName = 'supercars_parsec.png';
mech = game.add.sprite(250, 100, 'atlas');
mech.frameName = 'titan_mech.png';
}
})();
+50
View File
@@ -0,0 +1,50 @@
/// <reference path="../../Phaser/Game.ts" />
(function () {
var game = 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
game.load.atlas('atlas', 'assets/pics/texturepacker_test.png', 'assets/pics/texturepacker_test.json');
game.load.start();
}
var chick: Phaser.Sprite;
var car: Phaser.Sprite;
var mech: Phaser.Sprite;
var robot: Phaser.Sprite;
var cop: Phaser.Sprite;
function create() {
game.stage.backgroundColor = 'rgb(40, 40, 40)';
chick = game.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 = game.add.sprite(600, 64, 'atlas');
cop.frameName = 'ladycop.png';
robot = game.add.sprite(50, 300, 'atlas');
robot.frameName = 'robot.png';
car = game.add.sprite(100, 400, 'atlas');
car.frameName = 'supercars_parsec.png';
mech = game.add.sprite(250, 100, 'atlas');
mech.frameName = 'titan_mech.png';
}
})();
+22
View File
@@ -0,0 +1,22 @@
/// <reference path="../../Phaser/Game.ts" />
(function () {
var game = new Phaser.Game(this, 'game', 800, 600, init, create);
function init() {
game.load.image('atari', 'assets/sprites/atari130xe.png');
game.load.start();
}
var atari;
function create() {
atari = game.add.sprite(300, 0, 'atari');
startBounceTween();
}
function startBounceTween() {
atari.y = 0;
var bounce = game.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
@@ -0,0 +1,36 @@
/// <reference path="../../Phaser/Game.ts" />
(function () {
var game = new Phaser.Game(this, 'game', 800, 600, init, create);
function init() {
game.load.image('atari', 'assets/sprites/atari130xe.png');
game.load.start();
}
var atari: Phaser.Sprite;
function create() {
atari = game.add.sprite(300, 0, 'atari');
startBounceTween();
}
function startBounceTween() {
atari.y = 0;
var bounce: Phaser.Tween = game.add.tween(atari);
bounce.to({ y: 500 }, 1000 + Math.random() * 3000, Phaser.Easing.Bounce.Out);
bounce.onComplete.add(startBounceTween, this);
bounce.start();
}
})();
+7
View File
@@ -1,5 +1,7 @@
/// <reference path="../../Phaser/Game.ts" />
(function () {
var game = new Phaser.Game(this, 'game', 800, 600, init, create);
function init() {
@@ -7,8 +9,11 @@
game.load.spritesheet('PHASER', 'assets/tests/tween/PHASER.png', 70, 90);
game.load.start();
}
function create() {
var item: Phaser.Sprite;
for (var i = 0; i < 6; i++) {
item = game.add.sprite(190 + 69 * i, -100, 'PHASER', i);
// Add a simple bounce tween to each character's position.
@@ -18,5 +23,7 @@
// Set background color to white.
game.stage.backgroundColor = '#fff';
}
})();