Skip to content

Commit

Permalink
Added class constructors, fixed Stripshader, added relative Tween exa…
Browse files Browse the repository at this point in the history
…mple and updated Tween source.
  • Loading branch information
photonstorm committed Dec 30, 2013
1 parent fdbdd81 commit ce4cf53
Show file tree
Hide file tree
Showing 59 changed files with 324 additions and 149 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ Significant API changes:
* Loader.tileset has a new method signature. Please use the new format: load.tileset(key, url, tileWidth, tileHeight, tileMargin, tileSpacing, rows, columns, total).
* TilemapLayers are now created via the Tilemap object itself: map.createLayer(x, y, width, height, tileset, layer, group) and no longer via the GameObjectFactory.
* Tilemap.createFromObjects can now turn a bunch of Tiled objects into Sprites in one single call, and copies across all properties as well.
* Tween.onStartCallback and onCompleteCallback have been removed to avoid confusion. You should use the onStart, onLoop and onComplete events instead.


New features:
Expand All @@ -66,6 +67,7 @@ New features:
* Group.set will let you deep set a new propery on a single child of the Group.
* Stage.display property added. A direct reference to the root Pixi Stage object (very useful for RenderTexture manipulation)
* Added Ejecta detection to Device (thanks endel)
* Tweens can now work with relative + and - values. You can do: `tween(sprite).to( { x: '+400' })` and it will add 400 to the current sprite.x value, or '-400'.


New Examples:
Expand Down Expand Up @@ -104,6 +106,7 @@ Updates:
* Input doesn't set the cursor to default if it's already set to none.
* You can now collide a group against itself, to have all children collide, and bodies won't check against themselves (thanks cocoademon)
* RenderTexture.render / renderXY has a new parameter: renderHidden, a boolean which will allow you to render Sprites even if their visible is set to false.
* Added in prototype.constructor definitions to every class (thanks darkoverlordofdata)


Bug Fixes:
Expand All @@ -119,6 +122,8 @@ Bug Fixes:
* Tween.onStart is now called when the tween starts AFTER the delay value, if given (thanks stevenbouma)
* Sprites that are fixedToCamera can now be input dragged regardless of world position (thanks RafaelOliveira)
* RenderTexture now displays correctly in Canvas games.
* Canvas.addToDOM is now more robust when applying the overflowHidden style.
* Fixed Pixi.StripShader which should stop the weird TileSprite GPU issues some were reporting (thanks GoodboyDigital)


You can view the Change Log for all previous versions at https://github.com/photonstorm/phaser/changelog.md
Expand Down Expand Up @@ -266,6 +271,7 @@ Versions 1.2 ("Saldaea")

* Integration with the p2.js physics system.
* Enhance the State Management, so you can perform non-destructive State swaps and persistence.
* Update to Pixi 1.5 - currently still in dev branch only, but lots of nice internal changes and new features.

Beyond version 1.2

Expand Down
2 changes: 1 addition & 1 deletion build/phaser.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ declare module Phaser {
add(child: any): any;
addAt(child: any, index: number): any;
getAt(index: number): any;
create(x: number, y: number, key: string, frame: string, exists?: boolean): any;
create(x: number, y: number, key: string, frame?: any, exists?: boolean): Phaser.Sprite;
swap(child1: any, child2: any): boolean;
bringToTop(child: any): any;
getIndex(child: any): number;
Expand Down
4 changes: 2 additions & 2 deletions examples/games/breakout.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ function gameOver () {

ball.body.velocity.setTo(0, 0);

introText.content = "Game Over!";
introText.content = 'Game Over!';
introText.visible = true;

}
Expand All @@ -154,7 +154,7 @@ function ballHitBrick (_ball, _brick) {
// New level starts
score += 1000;
scoreText.content = 'score: ' + score;
introText = '- Next Level -';
introText.content = '- Next Level -';

// Let's move the ball back to the paddle
ballOnPaddle = true;
Expand Down
57 changes: 57 additions & 0 deletions examples/tweens/tween relative.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@

var game = new Phaser.Game(800, 600, Phaser.CANVAS, 'phaser-example', { preload: preload, create: create, render: render });

function preload() {

game.load.image('phaser', 'assets/sprites/phaser1.png');
game.load.spritesheet('arrows', 'assets/sprites/arrows.png', 23, 31);

}

var arrowStart;
var arrowEnd;
var sprite;

function create() {

game.stage.backgroundColor = '#2384e7';

arrowStart = game.add.sprite(100, 100, 'arrows', 0);

arrowEnd = game.add.sprite(400, 100, 'arrows', 1);

sprite = game.add.sprite(100, 164, 'phaser');
sprite.inputEnabled = true;

sprite.events.onInputDown.add(move, this);

}

function move() {

if (sprite.x === 100)
{
// Here you'll notice we are using a relative value for the tween.
// You can specify a number as a string with either + or - at the start of it.
// When the tween starts it will take the sprites current X value and add +300 to it.

game.add.tween(sprite).to( { x: '+300' }, 2000, Phaser.Easing.Linear.None, true);
}
else if (sprite.x === 400)
{
game.add.tween(sprite).to( { x: '-300' }, 2000, Phaser.Easing.Linear.None, true);
}

}

function render() {

if (sprite.x === 100 || sprite.x === 400)
{
game.debug.renderText('Click sprite to tween', 32, 32);
}

game.debug.renderText('x: ' + arrowStart.x, arrowStart.x, arrowStart.y - 4);
game.debug.renderText('x: ' + arrowEnd.x, arrowEnd.x, arrowEnd.y - 4);

}
57 changes: 57 additions & 0 deletions examples/wip/tween-relative.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@

var game = new Phaser.Game(800, 600, Phaser.CANVAS, 'phaser-example', { preload: preload, create: create, render: render });

function preload() {

game.load.image('phaser', 'assets/sprites/phaser1.png');
game.load.spritesheet('arrows', 'assets/sprites/arrows.png', 23, 31);

}

var arrowStart;
var arrowEnd;
var sprite;

function create() {

game.stage.backgroundColor = '#2384e7';

arrowStart = game.add.sprite(100, 100, 'arrows', 0);

arrowEnd = game.add.sprite(400, 100, 'arrows', 1);

sprite = game.add.sprite(100, 164, 'phaser');
sprite.inputEnabled = true;

sprite.events.onInputDown.add(move, this);

}

function move() {

if (sprite.x === 100)
{
// Here you'll notice we are using a relative value for the tween.
// You can specify a number as a string with either + or - at the start of it.
// When the tween starts it will take the sprites current X value and add +300 to it.

game.add.tween(sprite).to( { x: '+300' }, 2000, Phaser.Easing.Linear.None, true);
}
else if (sprite.x === 400)
{
game.add.tween(sprite).to( { x: '-300' }, 2000, Phaser.Easing.Linear.None, true);
}

}

function render() {

if (sprite.x === 100 || sprite.x === 400)
{
game.debug.renderText('Click sprite to tween', 32, 32);
}

game.debug.renderText('x: ' + arrowStart.x, arrowStart.x, arrowStart.y - 4);
game.debug.renderText('x: ' + arrowEnd.x, arrowEnd.x, arrowEnd.y - 4);

}
2 changes: 2 additions & 0 deletions src/animation/Animation.js
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,8 @@ Phaser.Animation.prototype = {

};

Phaser.Animation.prototype.constructor = Phaser.Animation;

/**
* @name Phaser.Animation#paused
* @property {boolean} paused - Gets and sets the paused state of this Animation.
Expand Down
2 changes: 2 additions & 0 deletions src/animation/AnimationManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,8 @@ Phaser.AnimationManager.prototype = {

};

Phaser.AnimationManager.prototype.constructor = Phaser.AnimationManager;

/**
* @name Phaser.AnimationManager#frameData
* @property {Phaser.FrameData} frameData - The current animations FrameData.
Expand Down
2 changes: 2 additions & 0 deletions src/animation/Frame.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,3 +158,5 @@ Phaser.Frame.prototype = {
}

};

Phaser.Frame.prototype.constructor = Phaser.Frame;
2 changes: 2 additions & 0 deletions src/animation/FrameData.js
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,8 @@ Phaser.FrameData.prototype = {

};

Phaser.FrameData.prototype.constructor = Phaser.FrameData;

/**
* @name Phaser.FrameData#total
* @property {number} total - The total number of frames in this FrameData set.
Expand Down
2 changes: 2 additions & 0 deletions src/core/Camera.js
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,8 @@ Phaser.Camera.prototype = {

};

Phaser.Camera.prototype.constructor = Phaser.Camera;

/**
* The Cameras x coordinate. This value is automatically clamped if it falls outside of the World bounds.
* @name Phaser.Camera#x
Expand Down
2 changes: 2 additions & 0 deletions src/core/Filter.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,8 @@ Phaser.Filter.prototype = {

};

Phaser.Filter.prototype.constructor = Phaser.Filter;

/**
* @name Phaser.Filter#width
* @property {number} width - The width (resolution uniform)
Expand Down
2 changes: 2 additions & 0 deletions src/core/Game.js
Original file line number Diff line number Diff line change
Expand Up @@ -635,6 +635,8 @@ Phaser.Game.prototype = {

};

Phaser.Game.prototype.constructor = Phaser.Game;

/**
* The paused state of the Game. A paused game doesn't update any of its subsystems.
* When a game is paused the onPause event is dispatched. When it is resumed the onResume event is dispatched.
Expand Down
2 changes: 2 additions & 0 deletions src/core/Group.js
Original file line number Diff line number Diff line change
Expand Up @@ -1495,6 +1495,8 @@ Phaser.Group.prototype = {

};

Phaser.Group.prototype.constructor = Phaser.Group;

/**
* @name Phaser.Group#total
* @property {number} total - The total number of children in this Group who have a state of exists = true.
Expand Down
4 changes: 3 additions & 1 deletion src/core/LinkedList.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,4 +151,6 @@ Phaser.LinkedList.prototype = {

}

};
};

Phaser.LinkedList.prototype.constructor = Phaser.LinkedList;
2 changes: 2 additions & 0 deletions src/core/Plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,3 +119,5 @@ Phaser.Plugin.prototype = {
}

};

Phaser.Plugin.prototype.constructor = Phaser.Plugin;
2 changes: 2 additions & 0 deletions src/core/PluginManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -295,3 +295,5 @@ Phaser.PluginManager.prototype = {
}

};

Phaser.PluginManager.prototype.constructor = Phaser.PluginManager;
2 changes: 2 additions & 0 deletions src/core/Signal.js
Original file line number Diff line number Diff line change
Expand Up @@ -300,3 +300,5 @@ Phaser.Signal.prototype = {
}

};

Phaser.Signal.prototype.constructor = Phaser.Signal;
2 changes: 2 additions & 0 deletions src/core/SignalBinding.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,3 +160,5 @@ Phaser.SignalBinding.prototype = {
}

};

Phaser.SignalBinding.prototype.constructor = Phaser.SignalBinding;
2 changes: 2 additions & 0 deletions src/core/Stage.js
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,8 @@ Phaser.Stage.prototype = {

};

Phaser.Stage.prototype.constructor = Phaser.Stage;

/**
* @name Phaser.Stage#backgroundColor
* @property {number|string} backgroundColor - Gets and sets the background color of the stage. The color can be given as a number: 0xff0000 or a hex string: '#ff0000'
Expand Down
2 changes: 2 additions & 0 deletions src/core/State.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,3 +167,5 @@ Phaser.State.prototype = {
}

};

Phaser.State.prototype.constructor = Phaser.State;
2 changes: 2 additions & 0 deletions src/core/StateManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -512,3 +512,5 @@ Phaser.StateManager.prototype = {
}

};

Phaser.StateManager.prototype.constructor = Phaser.StateManager;
4 changes: 3 additions & 1 deletion src/gameobjects/BitmapData.js
Original file line number Diff line number Diff line change
Expand Up @@ -957,7 +957,9 @@ Phaser.BitmapData.prototype = {

}

}
};

Phaser.BitmapData.prototype.constructor = Phaser.BitmapData;

// EaselJS Tiny API emulation

Expand Down
4 changes: 3 additions & 1 deletion src/gameobjects/Events.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,6 @@ Phaser.Events.prototype = {

}

};
};

Phaser.Events.prototype.constructor = Phaser.Events;
4 changes: 3 additions & 1 deletion src/gameobjects/GameObjectFactory.js
Original file line number Diff line number Diff line change
Expand Up @@ -318,4 +318,6 @@ Phaser.GameObjectFactory.prototype = {

}

};
};

Phaser.GameObjectFactory.prototype.constructor = Phaser.GameObjectFactory;
2 changes: 2 additions & 0 deletions src/geom/Circle.js
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,8 @@ Phaser.Circle.prototype = {

};

Phaser.Circle.prototype.constructor = Phaser.Circle;

/**
* The largest distance between any two points on the circle. The same as the radius * 2.
* @name Phaser.Circle#diameter
Expand Down
2 changes: 2 additions & 0 deletions src/geom/Point.js
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,8 @@ Phaser.Point.prototype = {

};

Phaser.Point.prototype.constructor = Phaser.Point;

/**
* Adds the coordinates of two points together to create a new point.
* @method Phaser.Point.add
Expand Down
2 changes: 2 additions & 0 deletions src/geom/Rectangle.js
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,8 @@ Phaser.Rectangle.prototype = {

};

Phaser.Rectangle.prototype.constructor = Phaser.Rectangle;

/**
* @name Phaser.Rectangle#halfWidth
* @property {number} halfWidth - Half of the width of the Rectangle.
Expand Down
2 changes: 2 additions & 0 deletions src/input/Input.js
Original file line number Diff line number Diff line change
Expand Up @@ -689,6 +689,8 @@ Phaser.Input.prototype = {

};

Phaser.Input.prototype.constructor = Phaser.Input;

/**
* The X coordinate of the most recently active pointer. This value takes game scaling into account automatically. See Pointer.screenX/clientX for source values.
* @name Phaser.Input#x
Expand Down
4 changes: 3 additions & 1 deletion src/input/InputHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -1106,4 +1106,6 @@ Phaser.InputHandler.prototype = {

}

};
};

Phaser.InputHandler.prototype.constructor = Phaser.InputHandler;
2 changes: 2 additions & 0 deletions src/input/Key.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,3 +169,5 @@ Phaser.Key.prototype = {
}

};

Phaser.Key.prototype.constructor = Phaser.Key;
2 changes: 2 additions & 0 deletions src/input/Keyboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,8 @@ Phaser.Keyboard.prototype = {

};

Phaser.Keyboard.prototype.constructor = Phaser.Keyboard;

Phaser.Keyboard.A = "A".charCodeAt(0);
Phaser.Keyboard.B = "B".charCodeAt(0);
Phaser.Keyboard.C = "C".charCodeAt(0);
Expand Down
Loading

0 comments on commit ce4cf53

Please sign in to comment.