diff --git a/Phaser/State.ts b/Phaser/State.ts index 6c22b4c4..698ef364 100644 --- a/Phaser/State.ts +++ b/Phaser/State.ts @@ -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} diff --git a/Phaser/components/animation/AnimationManager.ts b/Phaser/components/animation/AnimationManager.ts index aa4a860a..399c8e0b 100644 --- a/Phaser/components/animation/AnimationManager.ts +++ b/Phaser/components/animation/AnimationManager.ts @@ -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); + } } diff --git a/Phaser/components/sprite/Input.ts b/Phaser/components/sprite/Input.ts index 80ad9119..d7870af0 100644 --- a/Phaser/components/sprite/Input.ts +++ b/Phaser/components/sprite/Input.ts @@ -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 diff --git a/Phaser/gameobjects/Button.ts b/Phaser/gameobjects/Button.ts index 98c35fcf..bd354185 100644 --- a/Phaser/gameobjects/Button.ts +++ b/Phaser/gameobjects/Button.ts @@ -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; diff --git a/Phaser/gameobjects/DynamicTexture.ts b/Phaser/gameobjects/DynamicTexture.ts index 2f325e71..3bd7c60a 100644 --- a/Phaser/gameobjects/DynamicTexture.ts +++ b/Phaser/gameobjects/DynamicTexture.ts @@ -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 diff --git a/Phaser/gameobjects/Sprite.ts b/Phaser/gameobjects/Sprite.ts index 7c5d2e37..13858460 100644 --- a/Phaser/gameobjects/Sprite.ts +++ b/Phaser/gameobjects/Sprite.ts @@ -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; diff --git a/Phaser/geom/Rectangle.ts b/Phaser/geom/Rectangle.ts index c99dc156..a9a8f22a 100644 --- a/Phaser/geom/Rectangle.ts +++ b/Phaser/geom/Rectangle.ts @@ -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); diff --git a/Phaser/input/Mouse.ts b/Phaser/input/Mouse.ts index d1df7f7b..ddb27894 100644 --- a/Phaser/input/Mouse.ts +++ b/Phaser/input/Mouse.ts @@ -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); diff --git a/Phaser/loader/Loader.ts b/Phaser/loader/Loader.ts index 90a77546..5b381fee 100644 --- a/Phaser/loader/Loader.ts +++ b/Phaser/loader/Loader.ts @@ -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); } diff --git a/Phaser/physics/arcade/ArcadePhysics.ts b/Phaser/physics/arcade/ArcadePhysics.ts index 6fbe9864..573f0d20 100644 --- a/Phaser/physics/arcade/ArcadePhysics.ts +++ b/Phaser/physics/arcade/ArcadePhysics.ts @@ -32,7 +32,7 @@ module Phaser.Physics { } /** - * Local private reference to Game. + * Local reference to Game. */ public game: Game; diff --git a/Phaser/renderers/CanvasRenderer.ts b/Phaser/renderers/CanvasRenderer.ts index 4eda1576..48941738 100644 --- a/Phaser/renderers/CanvasRenderer.ts +++ b/Phaser/renderers/CanvasRenderer.ts @@ -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) { diff --git a/README.md b/README.md index 581c90c3..0bc98b88 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/Tests/Tests.csproj b/Tests/Tests.csproj index b8ef4ab0..0510a492 100644 --- a/Tests/Tests.csproj +++ b/Tests/Tests.csproj @@ -74,10 +74,27 @@ rotated buttons.ts + + + fade.ts + + + + scanlines.ts + basic camera 1.ts + + + + + + + + + scrollfactor 1.ts @@ -89,21 +106,43 @@ + world sprite.ts + + bring to top 1.ts + + create group 1.ts + display order.ts + + + + + + + + + + + + + + + + swap children.ts @@ -122,9 +161,12 @@ + game scale 1.ts + + motion lock 2.ts @@ -164,6 +206,12 @@ + + + + + + point1.ts @@ -175,6 +223,8 @@ point3.ts + + sprite test 1.ts @@ -202,10 +252,6 @@ - - - simple test 1.ts - ballscroller.ts @@ -229,17 +275,13 @@ skewed scroller.ts - alpha.ts - - atlas 1.ts - - - - atlas 2.ts + + + animate by framename.ts @@ -247,6 +289,8 @@ + + blur filter.ts @@ -271,9 +315,37 @@ sepia filter.ts + + + dynamic texture 1.ts + + + + dynamic texture 2.ts + filter test.ts + + + starling texture atlas.ts + + + + texture atlas 1.ts + + + + texture atlas 2.ts + + + + texture atlas 3.ts + + + + texture atlas 4.ts + csv tilemap.ts @@ -289,6 +361,16 @@ tiled tilemap.ts + + + bounce.ts + + + + + + + tween loop 1.ts @@ -350,6 +432,9 @@ boot screen.ts - + + + + \ No newline at end of file diff --git a/Tests/camera fx/fade.js b/Tests/camera fx/fade.js new file mode 100644 index 00000000..e69de29b diff --git a/Tests/camera fx/fade.ts b/Tests/camera fx/fade.ts new file mode 100644 index 00000000..e69de29b diff --git a/Tests/camera fx/scanlines.js b/Tests/camera fx/scanlines.js new file mode 100644 index 00000000..9d28a95d --- /dev/null +++ b/Tests/camera fx/scanlines.js @@ -0,0 +1,32 @@ +/// +/// +(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; + } + } +})(); diff --git a/Tests/camera fx/scanlines.ts b/Tests/camera fx/scanlines.ts new file mode 100644 index 00000000..18ad3caa --- /dev/null +++ b/Tests/camera fx/scanlines.ts @@ -0,0 +1,57 @@ +/// +/// + +(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 = 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; + } + + } + +})(); diff --git a/Tests/misc/dynamic texture 1.ts b/Tests/misc/dynamic texture 1.ts index bc171af5..d2e5e65c 100644 --- a/Tests/misc/dynamic texture 1.ts +++ b/Tests/misc/dynamic texture 1.ts @@ -1,3 +1,5 @@ +/// + (function() { var game = new Phaser.Game(this, 'game', 800, 600, null, create, null, render); diff --git a/Tests/phaser.js b/Tests/phaser.js index 007bfa83..b997ed0d 100644 --- a/Tests/phaser.js +++ b/Tests/phaser.js @@ -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; diff --git a/Tests/physics/simple test 1.js b/Tests/physics/simple test 1.js deleted file mode 100644 index f00fa461..00000000 --- a/Tests/physics/simple test 1.js +++ /dev/null @@ -1,45 +0,0 @@ -/// -(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); - } -})(); diff --git a/Tests/physics/simple test 1.ts b/Tests/physics/simple test 1.ts deleted file mode 100644 index 594a3d8b..00000000 --- a/Tests/physics/simple test 1.ts +++ /dev/null @@ -1,65 +0,0 @@ -/// - -(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); - - } - -})(); diff --git a/Tests/scrollzones/blasteroids.js b/Tests/scrollzones/blasteroids.js index cfdfe9cd..7d2ca1cd 100644 --- a/Tests/scrollzones/blasteroids.js +++ b/Tests/scrollzones/blasteroids.js @@ -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); diff --git a/Tests/scrollzones/blasteroids.ts b/Tests/scrollzones/blasteroids.ts index df050c54..7a998414 100644 --- a/Tests/scrollzones/blasteroids.ts +++ b/Tests/scrollzones/blasteroids.ts @@ -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; diff --git a/todo/phaser tests/sprites/animate by framename.js b/Tests/sprites/animate by framename.js similarity index 65% rename from todo/phaser tests/sprites/animate by framename.js rename to Tests/sprites/animate by framename.js index 0aaa7c21..ac6baf84 100644 --- a/todo/phaser tests/sprites/animate by framename.js +++ b/Tests/sprites/animate by framename.js @@ -1,13 +1,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'); - 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; } } })(); diff --git a/todo/phaser tests/sprites/animate by framename.ts b/Tests/sprites/animate by framename.ts similarity index 63% rename from todo/phaser tests/sprites/animate by framename.ts rename to Tests/sprites/animate by framename.ts index 6d253ca0..47581718 100644 --- a/todo/phaser tests/sprites/animate by framename.ts +++ b/Tests/sprites/animate by framename.ts @@ -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; } } diff --git a/Tests/sprites/atlas 1.js b/Tests/sprites/atlas 1.js deleted file mode 100644 index 8c21c9e1..00000000 --- a/Tests/sprites/atlas 1.js +++ /dev/null @@ -1,17 +0,0 @@ -/// -(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); - } -})(); diff --git a/Tests/sprites/atlas 1.ts b/Tests/sprites/atlas 1.ts deleted file mode 100644 index 67a80187..00000000 --- a/Tests/sprites/atlas 1.ts +++ /dev/null @@ -1,29 +0,0 @@ -/// - -(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); - - } - -})(); diff --git a/Tests/sprites/scale sprite 5.js b/Tests/sprites/scale sprite 5.js index c1fbef68..2447c9ae 100644 --- a/Tests/sprites/scale sprite 5.js +++ b/Tests/sprites/scale sprite 5.js @@ -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 diff --git a/Tests/sprites/scale sprite 5.ts b/Tests/sprites/scale sprite 5.ts index 0e8b2e1c..aa180503 100644 --- a/Tests/sprites/scale sprite 5.ts +++ b/Tests/sprites/scale sprite 5.ts @@ -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 diff --git a/Tests/sprites/sprite origin 2.js b/Tests/sprites/sprite origin 2.js index dee0dba8..d7443315 100644 --- a/Tests/sprites/sprite origin 2.js +++ b/Tests/sprites/sprite origin 2.js @@ -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); diff --git a/Tests/sprites/sprite origin 2.ts b/Tests/sprites/sprite origin 2.ts index 58b3c36c..4453e1d0 100644 --- a/Tests/sprites/sprite origin 2.ts +++ b/Tests/sprites/sprite origin 2.ts @@ -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); diff --git a/Tests/sprites/sprite origin 3.js b/Tests/sprites/sprite origin 3.js index 20ea3979..4c2a515a 100644 --- a/Tests/sprites/sprite origin 3.js +++ b/Tests/sprites/sprite origin 3.js @@ -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); diff --git a/Tests/sprites/sprite origin 3.ts b/Tests/sprites/sprite origin 3.ts index c61f1a3a..c4302397 100644 --- a/Tests/sprites/sprite origin 3.ts +++ b/Tests/sprites/sprite origin 3.ts @@ -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); diff --git a/Tests/sprites/sprite origin 4.js b/Tests/sprites/sprite origin 4.js index f075532d..73368191 100644 --- a/Tests/sprites/sprite origin 4.js +++ b/Tests/sprites/sprite origin 4.js @@ -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); diff --git a/Tests/sprites/sprite origin 4.ts b/Tests/sprites/sprite origin 4.ts index 4792e9eb..6fb43bf6 100644 --- a/Tests/sprites/sprite origin 4.ts +++ b/Tests/sprites/sprite origin 4.ts @@ -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); diff --git a/todo/phaser tests/sprites/dynamic texture 1.js b/Tests/textures/dynamic texture 1.js similarity index 68% rename from todo/phaser tests/sprites/dynamic texture 1.js rename to Tests/textures/dynamic texture 1.js index 89890eb9..620a7c38 100644 --- a/todo/phaser tests/sprites/dynamic texture 1.js +++ b/Tests/textures/dynamic texture 1.js @@ -1,23 +1,21 @@ /// (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++; } diff --git a/todo/phaser tests/sprites/dynamic texture 1.ts b/Tests/textures/dynamic texture 1.ts similarity index 66% rename from todo/phaser tests/sprites/dynamic texture 1.ts rename to Tests/textures/dynamic texture 1.ts index 88b75e3a..c5b0ee40 100644 --- a/todo/phaser tests/sprites/dynamic texture 1.ts +++ b/Tests/textures/dynamic texture 1.ts @@ -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; diff --git a/todo/phaser tests/misc/starfield.js b/Tests/textures/dynamic texture 2.js similarity index 64% rename from todo/phaser tests/misc/starfield.js rename to Tests/textures/dynamic texture 2.js index 55f3e468..3c98de4e 100644 --- a/todo/phaser tests/misc/starfield.js +++ b/Tests/textures/dynamic texture 2.js @@ -1,6 +1,6 @@ /// (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); } } diff --git a/todo/phaser tests/misc/starfield.ts b/Tests/textures/dynamic texture 2.ts similarity index 65% rename from todo/phaser tests/misc/starfield.ts rename to Tests/textures/dynamic texture 2.ts index ae5e0814..9fa030a8 100644 --- a/todo/phaser tests/misc/starfield.ts +++ b/Tests/textures/dynamic texture 2.ts @@ -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); } diff --git a/Tests/textures/starling texture atlas.js b/Tests/textures/starling texture atlas.js new file mode 100644 index 00000000..93710951 --- /dev/null +++ b/Tests/textures/starling texture atlas.js @@ -0,0 +1,31 @@ +/// +(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; + } + } + } +})(); diff --git a/Tests/textures/starling texture atlas.ts b/Tests/textures/starling texture atlas.ts new file mode 100644 index 00000000..3a211713 --- /dev/null +++ b/Tests/textures/starling texture atlas.ts @@ -0,0 +1,51 @@ +/// + +(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; + } + } + + } + +})(); diff --git a/Tests/sprites/atlas 2.js b/Tests/textures/texture atlas 1.js similarity index 98% rename from Tests/sprites/atlas 2.js rename to Tests/textures/texture atlas 1.js index 6eaa1c33..ae99cc46 100644 --- a/Tests/sprites/atlas 2.js +++ b/Tests/textures/texture atlas 1.js @@ -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) diff --git a/Tests/sprites/atlas 2.ts b/Tests/textures/texture atlas 1.ts similarity index 98% rename from Tests/sprites/atlas 2.ts rename to Tests/textures/texture atlas 1.ts index 1092c4c4..839a1f22 100644 --- a/Tests/sprites/atlas 2.ts +++ b/Tests/textures/texture atlas 1.ts @@ -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) diff --git a/todo/phaser tests/sprites/texture atlas.js b/Tests/textures/texture atlas 2.js similarity index 95% rename from todo/phaser tests/sprites/texture atlas.js rename to Tests/textures/texture atlas 2.js index ce5837bf..bc9d2b70 100644 --- a/todo/phaser tests/sprites/texture atlas.js +++ b/Tests/textures/texture atlas 2.js @@ -1,24 +1,24 @@ /// (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 = { diff --git a/todo/phaser tests/sprites/texture atlas.ts b/Tests/textures/texture atlas 2.ts similarity index 91% rename from todo/phaser tests/sprites/texture atlas.ts rename to Tests/textures/texture atlas 2.ts index 1aa46bff..44050693 100644 --- a/todo/phaser tests/sprites/texture atlas.ts +++ b/Tests/textures/texture atlas 2.ts @@ -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; } } diff --git a/todo/phaser tests/sprites/texture atlas 3.js b/Tests/textures/texture atlas 3.js similarity index 54% rename from todo/phaser tests/sprites/texture atlas 3.js rename to Tests/textures/texture atlas 3.js index b430c9fd..68f34d61 100644 --- a/todo/phaser tests/sprites/texture atlas 3.js +++ b/Tests/textures/texture atlas 3.js @@ -1,23 +1,23 @@ /// (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; } } })(); diff --git a/todo/phaser tests/sprites/texture atlas 3.ts b/Tests/textures/texture atlas 3.ts similarity index 57% rename from todo/phaser tests/sprites/texture atlas 3.ts rename to Tests/textures/texture atlas 3.ts index 49fec4fa..bcab4898 100644 --- a/todo/phaser tests/sprites/texture atlas 3.ts +++ b/Tests/textures/texture atlas 3.ts @@ -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; } } diff --git a/todo/phaser tests/sprites/texture atlas 4.js b/Tests/textures/texture atlas 4.js similarity index 58% rename from todo/phaser tests/sprites/texture atlas 4.js rename to Tests/textures/texture atlas 4.js index a5e7b5d1..6db30e4a 100644 --- a/todo/phaser tests/sprites/texture atlas 4.js +++ b/Tests/textures/texture atlas 4.js @@ -1,12 +1,12 @@ /// (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'; } })(); diff --git a/todo/phaser tests/sprites/texture atlas 4.ts b/Tests/textures/texture atlas 4.ts similarity index 61% rename from todo/phaser tests/sprites/texture atlas 4.ts rename to Tests/textures/texture atlas 4.ts index faf74f46..7eb3b98c 100644 --- a/todo/phaser tests/sprites/texture atlas 4.ts +++ b/Tests/textures/texture atlas 4.ts @@ -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'; } diff --git a/todo/phaser tests/tweens/bounce.js b/Tests/tweens/bounce.js similarity index 59% rename from todo/phaser tests/tweens/bounce.js rename to Tests/tweens/bounce.js index a50fd04b..61f010d9 100644 --- a/todo/phaser tests/tweens/bounce.js +++ b/Tests/tweens/bounce.js @@ -1,18 +1,18 @@ /// (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); diff --git a/todo/phaser tests/tweens/bounce.ts b/Tests/tweens/bounce.ts similarity index 59% rename from todo/phaser tests/tweens/bounce.ts rename to Tests/tweens/bounce.ts index 575cb950..067bdaab 100644 --- a/todo/phaser tests/tweens/bounce.ts +++ b/Tests/tweens/bounce.ts @@ -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); diff --git a/Tests/tweens/easing example 1.ts b/Tests/tweens/easing example 1.ts index fff2cad6..49900931 100644 --- a/Tests/tweens/easing example 1.ts +++ b/Tests/tweens/easing example 1.ts @@ -1,5 +1,7 @@ /// + (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'; + } + })(); diff --git a/build/phaser.d.ts b/build/phaser.d.ts index d78aeddd..94214b12 100644 --- a/build/phaser.d.ts +++ b/build/phaser.d.ts @@ -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; /** diff --git a/build/phaser.js b/build/phaser.js index 007bfa83..b997ed0d 100644 --- a/build/phaser.js +++ b/build/phaser.js @@ -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; diff --git a/todo/phaser tests/groups/basic group.js b/todo/phaser tests/groups/basic group.js deleted file mode 100644 index a0a1fae1..00000000 --- a/todo/phaser tests/groups/basic group.js +++ /dev/null @@ -1,39 +0,0 @@ -/// -(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); - } - } -})(); diff --git a/todo/phaser tests/groups/basic group.ts b/todo/phaser tests/groups/basic group.ts deleted file mode 100644 index 344b6898..00000000 --- a/todo/phaser tests/groups/basic group.ts +++ /dev/null @@ -1,66 +0,0 @@ -/// - -(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); - } - - } - -})(); diff --git a/todo/phaser tests/groups/display order.js b/todo/phaser tests/groups/display order.js deleted file mode 100644 index 089983b0..00000000 --- a/todo/phaser tests/groups/display order.js +++ /dev/null @@ -1,32 +0,0 @@ -/// -(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() { - } -})(); diff --git a/todo/phaser tests/groups/display order.ts b/todo/phaser tests/groups/display order.ts deleted file mode 100644 index 38a12f5a..00000000 --- a/todo/phaser tests/groups/display order.ts +++ /dev/null @@ -1,56 +0,0 @@ -/// - -(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 = 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() { - - } - -})(); diff --git a/todo/phaser tests/input/mouse scale.js b/todo/phaser tests/input/mouse scale.js deleted file mode 100644 index 9a4f2146..00000000 --- a/todo/phaser tests/input/mouse scale.js +++ /dev/null @@ -1,35 +0,0 @@ -/// -(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); - } -})(); diff --git a/todo/phaser tests/input/mouse scale.ts b/todo/phaser tests/input/mouse scale.ts deleted file mode 100644 index 6c6997cf..00000000 --- a/todo/phaser tests/input/mouse scale.ts +++ /dev/null @@ -1,62 +0,0 @@ -/// - -(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); - - } - -})(); diff --git a/todo/phaser tests/input/multitouch.js b/todo/phaser tests/input/multitouch.js deleted file mode 100644 index 02a627a8..00000000 --- a/todo/phaser tests/input/multitouch.js +++ /dev/null @@ -1,23 +0,0 @@ -/// -(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(); - } -})(); diff --git a/todo/phaser tests/input/multitouch.ts b/todo/phaser tests/input/multitouch.ts deleted file mode 100644 index b75d747f..00000000 --- a/todo/phaser tests/input/multitouch.ts +++ /dev/null @@ -1,40 +0,0 @@ -/// - -(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(); - - } - -})(); diff --git a/todo/phaser tests/input/single tap.js b/todo/phaser tests/input/single tap.js deleted file mode 100644 index efbae556..00000000 --- a/todo/phaser tests/input/single tap.js +++ /dev/null @@ -1,39 +0,0 @@ -/// -(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); - } -})(); diff --git a/todo/phaser tests/input/single tap.ts b/todo/phaser tests/input/single tap.ts deleted file mode 100644 index db3e525a..00000000 --- a/todo/phaser tests/input/single tap.ts +++ /dev/null @@ -1,64 +0,0 @@ -/// - -(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 = 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); - - } - -})(); diff --git a/todo/phaser tests/input/single touch.js b/todo/phaser tests/input/single touch.js deleted file mode 100644 index 3dc654d4..00000000 --- a/todo/phaser tests/input/single touch.js +++ /dev/null @@ -1,19 +0,0 @@ -/// -(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); - } -})(); diff --git a/todo/phaser tests/input/single touch.ts b/todo/phaser tests/input/single touch.ts deleted file mode 100644 index 57570ddf..00000000 --- a/todo/phaser tests/input/single touch.ts +++ /dev/null @@ -1,31 +0,0 @@ -/// - -(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); - - } - -})(); diff --git a/todo/phaser tests/misc/bootscreen.js b/todo/phaser tests/misc/bootscreen.js deleted file mode 100644 index 57cb3bfa..00000000 --- a/todo/phaser tests/misc/bootscreen.js +++ /dev/null @@ -1,4 +0,0 @@ -/// -(function () { - var myGame = new Phaser.Game(this, 'game', 800, 600); -})(); diff --git a/todo/phaser tests/misc/bootscreen.ts b/todo/phaser tests/misc/bootscreen.ts deleted file mode 100644 index f0a67343..00000000 --- a/todo/phaser tests/misc/bootscreen.ts +++ /dev/null @@ -1,7 +0,0 @@ -/// - -(function () { - - var myGame = new Phaser.Game(this, 'game', 800, 600); - -})(); diff --git a/todo/phaser tests/scrollzones/ballscroller.js b/todo/phaser tests/scrollzones/ballscroller.js deleted file mode 100644 index 3934d00b..00000000 --- a/todo/phaser tests/scrollzones/ballscroller.js +++ /dev/null @@ -1,25 +0,0 @@ -/// -/// -(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(); - } -})(); diff --git a/todo/phaser tests/scrollzones/ballscroller.ts b/todo/phaser tests/scrollzones/ballscroller.ts deleted file mode 100644 index 753243c7..00000000 --- a/todo/phaser tests/scrollzones/ballscroller.ts +++ /dev/null @@ -1,41 +0,0 @@ -/// -/// - -(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(); - - } - -})(); diff --git a/todo/phaser tests/scrollzones/blasteroids.js b/todo/phaser tests/scrollzones/blasteroids.js deleted file mode 100644 index 422197ad..00000000 --- a/todo/phaser tests/scrollzones/blasteroids.js +++ /dev/null @@ -1,95 +0,0 @@ -/// -/// -(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; - } - } -})(); diff --git a/todo/phaser tests/scrollzones/blasteroids.ts b/todo/phaser tests/scrollzones/blasteroids.ts deleted file mode 100644 index c7cf776d..00000000 --- a/todo/phaser tests/scrollzones/blasteroids.ts +++ /dev/null @@ -1,151 +0,0 @@ -/// -/// - -(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; - } - - } - -})(); diff --git a/todo/phaser tests/scrollzones/parallax.js b/todo/phaser tests/scrollzones/parallax.js deleted file mode 100644 index d3e91cb4..00000000 --- a/todo/phaser tests/scrollzones/parallax.js +++ /dev/null @@ -1,31 +0,0 @@ -/// -/// -(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; - } - } - } -})(); diff --git a/todo/phaser tests/scrollzones/parallax.ts b/todo/phaser tests/scrollzones/parallax.ts deleted file mode 100644 index 5f74a294..00000000 --- a/todo/phaser tests/scrollzones/parallax.ts +++ /dev/null @@ -1,53 +0,0 @@ -/// -/// - -(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; - } - } - - } - -})(); diff --git a/todo/phaser tests/scrollzones/region demo.js b/todo/phaser tests/scrollzones/region demo.js deleted file mode 100644 index 9a0f1d29..00000000 --- a/todo/phaser tests/scrollzones/region demo.js +++ /dev/null @@ -1,22 +0,0 @@ -/// -/// -(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); - } -})(); diff --git a/todo/phaser tests/scrollzones/region demo.ts b/todo/phaser tests/scrollzones/region demo.ts deleted file mode 100644 index beabb6f0..00000000 --- a/todo/phaser tests/scrollzones/region demo.ts +++ /dev/null @@ -1,37 +0,0 @@ -/// -/// - -(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); - - } - -})(); diff --git a/todo/phaser tests/scrollzones/scroll window.js b/todo/phaser tests/scrollzones/scroll window.js deleted file mode 100644 index 835558c6..00000000 --- a/todo/phaser tests/scrollzones/scroll window.js +++ /dev/null @@ -1,18 +0,0 @@ -/// -/// -(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'); - } -})(); diff --git a/todo/phaser tests/scrollzones/scroll window.ts b/todo/phaser tests/scrollzones/scroll window.ts deleted file mode 100644 index 52f1ebbb..00000000 --- a/todo/phaser tests/scrollzones/scroll window.ts +++ /dev/null @@ -1,31 +0,0 @@ -/// -/// - -(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'); - - } - -})(); diff --git a/todo/phaser tests/scrollzones/simple scrollzone.js b/todo/phaser tests/scrollzones/simple scrollzone.js deleted file mode 100644 index 4b2466c6..00000000 --- a/todo/phaser tests/scrollzones/simple scrollzone.js +++ /dev/null @@ -1,16 +0,0 @@ -/// -/// -(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); - } -})(); diff --git a/todo/phaser tests/scrollzones/simple scrollzone.ts b/todo/phaser tests/scrollzones/simple scrollzone.ts deleted file mode 100644 index 31ecfd1d..00000000 --- a/todo/phaser tests/scrollzones/simple scrollzone.ts +++ /dev/null @@ -1,28 +0,0 @@ -/// -/// - -(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); - - } - -})(); diff --git a/todo/phaser tests/sprites/align.js b/todo/phaser tests/sprites/align.js deleted file mode 100644 index 0bbd6f93..00000000 --- a/todo/phaser tests/sprites/align.js +++ /dev/null @@ -1,27 +0,0 @@ -/// -(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; - } -})(); diff --git a/todo/phaser tests/sprites/align.ts b/todo/phaser tests/sprites/align.ts deleted file mode 100644 index be666803..00000000 --- a/todo/phaser tests/sprites/align.ts +++ /dev/null @@ -1,50 +0,0 @@ -/// - -(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; - - } - -})(); diff --git a/todo/phaser tests/sprites/starling texture atlas 1.js b/todo/phaser tests/sprites/starling texture atlas 1.js deleted file mode 100644 index fc7cdeee..00000000 --- a/todo/phaser tests/sprites/starling texture atlas 1.js +++ /dev/null @@ -1,32 +0,0 @@ -/// -(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; - } - } - } -})(); diff --git a/todo/phaser tests/sprites/starling texture atlas 1.ts b/todo/phaser tests/sprites/starling texture atlas 1.ts deleted file mode 100644 index c6dc0d8f..00000000 --- a/todo/phaser tests/sprites/starling texture atlas 1.ts +++ /dev/null @@ -1,52 +0,0 @@ -/// - -(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; - } - } - - } - -})(); diff --git a/todo/phaser tests/sprites/texture atlas 2.js b/todo/phaser tests/sprites/texture atlas 2.js deleted file mode 100644 index 1fb6d2a8..00000000 --- a/todo/phaser tests/sprites/texture atlas 2.js +++ /dev/null @@ -1,25 +0,0 @@ -/// -(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 }}]}'; -})(); diff --git a/todo/phaser tests/sprites/texture atlas 2.ts b/todo/phaser tests/sprites/texture atlas 2.ts deleted file mode 100644 index 7ae3264b..00000000 --- a/todo/phaser tests/sprites/texture atlas 2.ts +++ /dev/null @@ -1,43 +0,0 @@ -/// - -(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 }}]}'; - -})(); diff --git a/todo/phaser tests/tweens/elastic.js b/todo/phaser tests/tweens/elastic.js deleted file mode 100644 index 5d793f57..00000000 --- a/todo/phaser tests/tweens/elastic.js +++ /dev/null @@ -1,15 +0,0 @@ -/// -(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); - } -})(); diff --git a/todo/phaser tests/tweens/elastic.ts b/todo/phaser tests/tweens/elastic.ts deleted file mode 100644 index 6d60f5b7..00000000 --- a/todo/phaser tests/tweens/elastic.ts +++ /dev/null @@ -1,24 +0,0 @@ -/// - -(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); - - } - -})();