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
-7
View File
@@ -24,7 +24,6 @@ module 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;
@@ -74,12 +73,6 @@ module Phaser {
*/
public math: GameMath;
/**
* Reference to the motion helper.
* @type {Motion}
*/
//public motion: Motion;
/**
* Reference to the sound manager.
* @type {SoundManager}
@@ -268,7 +268,7 @@ module Phaser.Components {
public set frameName(value: string) {
if (this._frameData.getFrameByName(value))
if (this._frameData && this._frameData.getFrameByName(value))
{
this.currentFrame = this._frameData.getFrameByName(value);
@@ -277,6 +277,10 @@ module Phaser.Components {
this._frameIndex = this.currentFrame.index;
}
else
{
throw new Error("Cannot set frameName: " + value);
}
}
+2 -1
View File
@@ -241,7 +241,6 @@ module Phaser.Components.Sprite {
this._parent.events.onDragStart = new Phaser.Signal;
this._parent.events.onDragStop = new Phaser.Signal;
}
}
return this._parent;
@@ -381,6 +380,7 @@ module Phaser.Components.Sprite {
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
@@ -416,6 +416,7 @@ module Phaser.Components.Sprite {
// Only release the InputUp signal if the pointer is still over this sprite
if (SpriteUtils.overlapsXY(this._parent, pointer.worldX(), pointer.worldY()))
{
//console.log('releasedHandler: ' + Date.now());
this._parent.events.onInputUp.dispatch(this._parent, pointer);
}
else
+4
View File
@@ -161,6 +161,8 @@ module Phaser {
private onInputDownHandler(pointer:Phaser.Pointer) {
//console.log('Button onInputDownHandler: ' + Date.now());
if (this._onDownFrameName != null)
{
this.frameName = this._onDownFrameName;
@@ -179,6 +181,8 @@ module Phaser {
private onInputUpHandler(pointer:Phaser.Pointer) {
//console.log('Button onInputUpHandler: ' + Date.now());
if (this._onUpFrameName != null)
{
this.frameName = this._onUpFrameName;
+7
View File
@@ -265,6 +265,13 @@ module Phaser {
}
public add(sprite: Sprite) {
sprite.texture.canvas = this.canvas;
sprite.texture.context = this.context;
}
/**
* 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
+1 -1
View File
@@ -139,7 +139,7 @@ module Phaser {
/**
* The action to be taken when the sprite is fully out of the world bounds
* Defaults to Phaser.Types.OUT_OF_BOUNDS_KILL
* Defaults to Phaser.Types.OUT_OF_BOUNDS_PERSIST
*/
public outOfBoundsAction: number;
+1 -1
View File
@@ -239,7 +239,7 @@ module Phaser {
/**
* 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.
**/
get empty(): bool {
return (!this.width || !this.height);
+6
View File
@@ -50,6 +50,12 @@ module Phaser {
*/
public start() {
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', (event: MouseEvent) => this.onMouseDown(event), true);
this._game.stage.canvas.addEventListener('mousemove', (event: MouseEvent) => this.onMouseMove(event), true);
this._game.stage.canvas.addEventListener('mouseup', (event: MouseEvent) => this.onMouseUp(event), true);
+4
View File
@@ -413,6 +413,8 @@ module Phaser {
this._fileList[key].loaded = true;
this._fileList[key].error = true;
throw new Error("Phaser.Loader error loading file: " + key);
this.nextFile(key, false);
}
@@ -531,6 +533,8 @@ module Phaser {
file.error = true;
throw new Error("Phaser.Loader dataLoadError: " + key);
this.nextFile(key, true);
}
+1 -1
View File
@@ -32,7 +32,7 @@ module Phaser.Physics {
}
/**
* Local private reference to Game.
* Local reference to Game.
*/
public game: Game;
+35 -27
View File
@@ -458,11 +458,6 @@ module Phaser {
return false;
}
if (sprite.crop && sprite.crop.empty)
{
return;
}
sprite.renderOrderID = this._count;
this._count++;
@@ -478,20 +473,6 @@ module Phaser {
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;
@@ -540,16 +521,43 @@ module 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.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);
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;
}
if (sprite.texture.opaque)
{
+1 -7
View File
@@ -25,13 +25,10 @@ TODO:
* Dispatch world resize event
* Investigate why tweens don't restart after the game pauses
* Fix bug in Tween yoyo + loop combo
* Apply Sprite scaling to Body.bounds
* Check that tween pausing works with the new performance.now
* Game.Time should monitor pause duration
* Investigate bug re: tilemap collision and animation frames
* Update tests that use arrow keys and include touch/mouse support (FlxControlHandler style)
* Texture Repeat doesn't scroll, because it's part of the camera not the world, need to think about this more
* Add JSON Texture Atlas object support.
* Pointer.getWorldX(camera) needs to take camera scale into consideration
* If stage.clear set to false and game pauses, when it unpauses you still see the pause arrow - resolve this
* Add clip support + shape options to Texture Component.
@@ -44,11 +41,7 @@ TODO:
* See which functions in the input component can move elsewhere (utils)
* Move all of the renderDebugInfo methods to the DebugUtils class
* Check bounds/edge points when sprite is only 1x1 sized :)
* See what I can move out of Body and into a BodyUtils class.
* See about optimising Advanced Physics a lot more, so it doesn't create lots of Vec2s everywhere.
* QuadTree.physics.checkHullIntersection
* Fix the Motion methods for the new physics system
* Move findShapeByPoint etc from Space to Manager (or at least add a proxy to them)
* Add visible toggle if tween property is alpha <> 01
* Camera.isHidden uses an array and length check, faster to swap for a single counter, also try to remove indexOf check
* Tilemap.render - move layers length to var
@@ -69,6 +62,7 @@ TODO:
* Pixel-perfect click check
* Check Flash atlas export is supported
* Plug-in Support
* DynamicTexture.setPixel needs to be swapped for a proper pixel put, not the filledRect it currently is.
+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;
@@ -1,13 +1,13 @@
/// <reference path="../../Phaser/Game.ts" />
(function () {
var myGame = new Phaser.Game(this, 'game', 800, 600, init, create, update);
var game = 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();
game.load.atlas('bot', 'assets/sprites/running_bot.png', 'assets/sprites/running_bot.json');
game.load.start();
}
var bot;
function create() {
bot = myGame.add.sprite(myGame.stage.width, 300, 'bot');
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', [
@@ -24,11 +24,12 @@
'run10'
], 10, true, false);
bot.animations.play('run');
bot.velocity.x = -100;
}
//bot.velocity.x = -100;
}
function update() {
bot.x -= 1;
if(bot.x < -bot.width) {
bot.x = myGame.stage.width;
bot.x = game.stage.width;
}
}
})();
@@ -2,13 +2,13 @@
(function () {
var myGame = new Phaser.Game(this, 'game', 800, 600, init, create, update);
var game = 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');
game.load.atlas('bot', 'assets/sprites/running_bot.png', 'assets/sprites/running_bot.json');
myGame.loader.load();
game.load.start();
}
@@ -16,7 +16,7 @@
function create() {
bot = myGame.add.sprite(myGame.stage.width, 300, 'bot');
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:
@@ -24,15 +24,17 @@
bot.animations.play('run');
bot.velocity.x = -100;
//bot.velocity.x = -100;
}
function update() {
bot.x -= 1;
if (bot.x < -bot.width)
{
bot.x = myGame.stage.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);
@@ -1,23 +1,21 @@
/// <reference path="../../Phaser/Game.ts" />
(function () {
var myGame = new Phaser.Game(this, 'game', 800, 600, init, create, update);
var game = new Phaser.Game(this, 'game', 800, 600, init, create, update);
function init() {
myGame.loader.addImageFile('ball', 'assets/sprites/shinyball.png');
myGame.loader.load();
game.load.image('ball', 'assets/sprites/shinyball.png');
game.load.start();
}
var wobblyBall;
function create() {
// Create our DynamicTexture
wobblyBall = myGame.add.dynamicTexture(32, 64);
wobblyBall = game.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);
var temp = game.add.sprite(game.world.randomX, game.world.randomY);
temp.texture.loadDynamicTexture(wobblyBall);
}
// Populate the wave with some data
waveData = myGame.math.sinCosGenerator(32, 8, 8, 2);
waveData = game.math.sinCosGenerator(32, 8, 8, 2);
}
function update() {
wobblyBall.clear();
@@ -44,7 +42,7 @@
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);
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++;
}
@@ -2,13 +2,13 @@
(function () {
var myGame = new Phaser.Game(this, 'game', 800, 600, init, create, update);
var game = new Phaser.Game(this, 'game', 800, 600, init, create, update);
function init() {
myGame.loader.addImageFile('ball', 'assets/sprites/shinyball.png');
game.load.image('ball', 'assets/sprites/shinyball.png');
myGame.loader.load();
game.load.start();
}
@@ -17,19 +17,17 @@
function create() {
// Create our DynamicTexture
wobblyBall = myGame.add.dynamicTexture(32, 64);
wobblyBall = game.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);
var temp = game.add.sprite(game.world.randomX, game.world.randomY);
temp.texture.loadDynamicTexture(wobblyBall);
}
// Populate the wave with some data
waveData = myGame.math.sinCosGenerator(32, 8, 8, 2);
waveData = game.math.sinCosGenerator(32, 8, 8, 2);
}
@@ -60,7 +58,7 @@
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);
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;
@@ -1,6 +1,6 @@
/// <reference path="../../Phaser/Game.ts" />
(function () {
var myGame = new Phaser.Game(this, 'game', 800, 600, null, create, update, render);
var game = new Phaser.Game(this, 'game', 800, 600, null, create, update, render);
var starfield;
var xx = [];
var yy = [];
@@ -8,14 +8,14 @@
var xxx = 0;
var yyy = 0;
function create() {
// the width of the starfield
// 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);
starfield = game.add.dynamicTexture(800, 600);
}
function update() {
starfield.clear();
@@ -25,18 +25,14 @@
}
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 + 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';
}
//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);
}
}
@@ -2,7 +2,7 @@
(function () {
var myGame = new Phaser.Game(this, 'game', 800, 600, null, create, update, render);
var game = new Phaser.Game(this, 'game', 800, 600, null, create, update, render);
var starfield: Phaser.DynamicTexture;
@@ -14,7 +14,7 @@
function create() {
// the width of the starfield
// The width of the starfield
var star_w: number = 12000;
for (var i: number = 0; i < 800; i++)
@@ -24,7 +24,7 @@
zz[i] = Math.floor(Math.random() * 160) + 1;
}
starfield = myGame.add.dynamicTexture(800, 600);
starfield = game.add.dynamicTexture(800, 600);
}
@@ -34,18 +34,23 @@
for (var i: number = 0; i < 800; i++)
{
if (zz[i] == 1) zz[i] = 100;
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 + 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';
//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);
}
+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)
@@ -1,24 +1,24 @@
/// <reference path="../../Phaser/Game.ts" />
(function () {
var myGame = new Phaser.Game(this, 'game', 800, 600, init, create, update);
var game = new Phaser.Game(this, 'game', 800, 600, init, create, update);
function init() {
// Texture Atlas Method 1
// 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)
myGame.loader.addTextureAtlas('bot', 'assets/sprites/running_bot.png', null, botData);
myGame.loader.load();
game.load.atlas('bot', 'assets/sprites/running_bot.png', null, botData);
game.load.start();
}
var bot;
function create() {
bot = myGame.add.sprite(myGame.stage.width, 300, 'bot');
bot = game.add.sprite(game.stage.width, 300, 'bot');
bot.animations.add('run');
bot.animations.play('run', 10, true);
bot.velocity.x = -100;
}
function update() {
bot.x -= 2;
if(bot.x < -bot.width) {
bot.x = myGame.stage.width;
bot.x = game.stage.width;
}
}
var botData = {
@@ -2,17 +2,17 @@
(function () {
var myGame = new Phaser.Game(this, 'game', 800, 600, init, create, update);
var game = new Phaser.Game(this, 'game', 800, 600, init, create, update);
function init() {
// Texture Atlas Method 1
// 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)
myGame.loader.addTextureAtlas('bot', 'assets/sprites/running_bot.png', null, botData);
game.load.atlas('bot', 'assets/sprites/running_bot.png', null, botData);
myGame.loader.load();
game.load.start();
}
@@ -20,20 +20,20 @@
function create() {
bot = myGame.add.sprite(myGame.stage.width, 300, 'bot');
bot = game.add.sprite(game.stage.width, 300, 'bot');
bot.animations.add('run');
bot.animations.play('run', 10, true);
bot.velocity.x = -100;
}
function update() {
bot.x -= 2;
if (bot.x < -bot.width)
{
bot.x = myGame.stage.width;
bot.x = game.stage.width;
}
}
@@ -1,23 +1,23 @@
/// <reference path="../../Phaser/Game.ts" />
(function () {
var myGame = new Phaser.Game(this, 'game', 800, 600, init, create, update);
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
myGame.loader.addTextureAtlas('bot', 'assets/sprites/running_bot.png', 'assets/sprites/running_bot.json');
myGame.loader.load();
game.load.atlas('bot', 'assets/sprites/running_bot.png', 'assets/sprites/running_bot.json');
game.load.start();
}
var bot;
function create() {
bot = myGame.add.sprite(myGame.stage.width, 300, 'bot');
bot = game.add.sprite(game.stage.width, 300, 'bot');
bot.animations.add('run');
bot.animations.play('run', 10, true);
bot.velocity.x = -100;
}
function update() {
bot.x -= 2;
if(bot.x < -bot.width) {
bot.x = myGame.stage.width;
bot.x = game.stage.width;
}
}
})();
@@ -2,16 +2,16 @@
(function () {
var myGame = new Phaser.Game(this, 'game', 800, 600, init, create, update);
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
myGame.loader.addTextureAtlas('bot', 'assets/sprites/running_bot.png', 'assets/sprites/running_bot.json');
game.load.atlas('bot', 'assets/sprites/running_bot.png', 'assets/sprites/running_bot.json');
myGame.loader.load();
game.load.start();
}
@@ -19,20 +19,20 @@
function create() {
bot = myGame.add.sprite(myGame.stage.width, 300, 'bot');
bot = game.add.sprite(game.stage.width, 300, 'bot');
bot.animations.add('run');
bot.animations.play('run', 10, true);
bot.velocity.x = -100;
}
function update() {
bot.x -= 2;
if (bot.x < -bot.width)
{
bot.x = myGame.stage.width;
bot.x = game.stage.width;
}
}
@@ -1,12 +1,12 @@
/// <reference path="../../Phaser/Game.ts" />
(function () {
var myGame = new Phaser.Game(this, 'game', 800, 600, init, create);
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
myGame.loader.addTextureAtlas('atlas', 'assets/pics/texturepacker_test.png', 'assets/pics/texturepacker_test.json');
myGame.loader.load();
game.load.atlas('atlas', 'assets/pics/texturepacker_test.png', 'assets/pics/texturepacker_test.json');
game.load.start();
}
var chick;
var car;
@@ -14,19 +14,19 @@
var robot;
var cop;
function create() {
myGame.camera.backgroundColor = 'rgb(40, 40, 40)';
chick = myGame.add.sprite(64, 64, 'atlas');
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 = myGame.add.sprite(600, 64, 'atlas');
cop = game.add.sprite(600, 64, 'atlas');
cop.frameName = 'ladycop.png';
robot = myGame.add.sprite(50, 300, 'atlas');
robot = game.add.sprite(50, 300, 'atlas');
robot.frameName = 'robot.png';
car = myGame.add.sprite(100, 400, 'atlas');
car = game.add.sprite(100, 400, 'atlas');
car.frameName = 'supercars_parsec.png';
mech = myGame.add.sprite(250, 100, 'atlas');
mech = game.add.sprite(250, 100, 'atlas');
mech.frameName = 'titan_mech.png';
}
})();
@@ -2,16 +2,16 @@
(function () {
var myGame = new Phaser.Game(this, 'game', 800, 600, init, create);
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
myGame.loader.addTextureAtlas('atlas', 'assets/pics/texturepacker_test.png', 'assets/pics/texturepacker_test.json');
game.load.atlas('atlas', 'assets/pics/texturepacker_test.png', 'assets/pics/texturepacker_test.json');
myGame.loader.load();
game.load.start();
}
@@ -23,9 +23,9 @@
function create() {
myGame.camera.backgroundColor = 'rgb(40, 40, 40)';
game.stage.backgroundColor = 'rgb(40, 40, 40)';
chick = myGame.add.sprite(64, 64, 'atlas');
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';
@@ -33,16 +33,16 @@
// Or by setting the frame index
//chick.frame = 0;
cop = myGame.add.sprite(600, 64, 'atlas');
cop = game.add.sprite(600, 64, 'atlas');
cop.frameName = 'ladycop.png';
robot = myGame.add.sprite(50, 300, 'atlas');
robot = game.add.sprite(50, 300, 'atlas');
robot.frameName = 'robot.png';
car = myGame.add.sprite(100, 400, 'atlas');
car = game.add.sprite(100, 400, 'atlas');
car.frameName = 'supercars_parsec.png';
mech = myGame.add.sprite(250, 100, 'atlas');
mech = game.add.sprite(250, 100, 'atlas');
mech.frameName = 'titan_mech.png';
}
@@ -1,18 +1,18 @@
/// <reference path="../../Phaser/Game.ts" />
(function () {
var myGame = new Phaser.Game(this, 'game', 800, 600, init, create);
var game = new Phaser.Game(this, 'game', 800, 600, init, create);
function init() {
myGame.loader.addImageFile('atari', 'assets/sprites/atari130xe.png');
myGame.loader.load();
game.load.image('atari', 'assets/sprites/atari130xe.png');
game.load.start();
}
var atari;
function create() {
atari = myGame.add.sprite(300, 0, 'atari');
atari = game.add.sprite(300, 0, 'atari');
startBounceTween();
}
function startBounceTween() {
atari.y = 0;
var bounce = myGame.add.tween(atari);
var bounce = game.add.tween(atari);
bounce.to({
y: 500
}, 1000 + Math.random() * 3000, Phaser.Easing.Bounce.Out);
@@ -2,13 +2,13 @@
(function () {
var myGame = new Phaser.Game(this, 'game', 800, 600, init, create);
var game = new Phaser.Game(this, 'game', 800, 600, init, create);
function init() {
myGame.loader.addImageFile('atari', 'assets/sprites/atari130xe.png');
game.load.image('atari', 'assets/sprites/atari130xe.png');
myGame.loader.load();
game.load.start();
}
@@ -16,7 +16,7 @@
function create() {
atari = myGame.add.sprite(300, 0, 'atari');
atari = game.add.sprite(300, 0, 'atari');
startBounceTween();
}
@@ -25,7 +25,7 @@
atari.y = 0;
var bounce: Phaser.Tween = myGame.add.tween(atari);
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);
+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';
}
})();
+4 -3
View File
@@ -177,7 +177,7 @@ module Phaser {
/**
* 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.
**/
/**
* Sets all of the Rectangle object's properties to 0. A Rectangle object is empty if its width or height is less than or equal to 0.
@@ -1409,6 +1409,7 @@ module Phaser {
* @param destPoint {Point} Top-left point the target image data will be paste at.
*/
public copyPixels(sourceTexture: DynamicTexture, sourceRect: Rectangle, destPoint: Point): void;
public add(sprite: Sprite): void;
/**
* 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
@@ -2706,7 +2707,7 @@ module Phaser.Physics {
class ArcadePhysics {
constructor(game: Game, width: number, height: number);
/**
* Local private reference to Game.
* Local reference to Game.
*/
public game: Game;
/**
@@ -2929,7 +2930,7 @@ module Phaser {
public outOfBounds: bool;
/**
* The action to be taken when the sprite is fully out of the world bounds
* Defaults to Phaser.Types.OUT_OF_BOUNDS_KILL
* Defaults to Phaser.Types.OUT_OF_BOUNDS_PERSIST
*/
public outOfBoundsAction: number;
/**
+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;
-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);
})();
@@ -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,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 }}]}';
})();
-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);
}
})();