Skip to content

Commit ce4cf53

Browse files
committed
Added class constructors, fixed Stripshader, added relative Tween example and updated Tween source.
1 parent fdbdd81 commit ce4cf53

59 files changed

Lines changed: 324 additions & 149 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ Significant API changes:
4949
* Loader.tileset has a new method signature. Please use the new format: load.tileset(key, url, tileWidth, tileHeight, tileMargin, tileSpacing, rows, columns, total).
5050
* TilemapLayers are now created via the Tilemap object itself: map.createLayer(x, y, width, height, tileset, layer, group) and no longer via the GameObjectFactory.
5151
* Tilemap.createFromObjects can now turn a bunch of Tiled objects into Sprites in one single call, and copies across all properties as well.
52+
* Tween.onStartCallback and onCompleteCallback have been removed to avoid confusion. You should use the onStart, onLoop and onComplete events instead.
5253

5354

5455
New features:
@@ -66,6 +67,7 @@ New features:
6667
* Group.set will let you deep set a new propery on a single child of the Group.
6768
* Stage.display property added. A direct reference to the root Pixi Stage object (very useful for RenderTexture manipulation)
6869
* Added Ejecta detection to Device (thanks endel)
70+
* 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'.
6971

7072

7173
New Examples:
@@ -104,6 +106,7 @@ Updates:
104106
* Input doesn't set the cursor to default if it's already set to none.
105107
* You can now collide a group against itself, to have all children collide, and bodies won't check against themselves (thanks cocoademon)
106108
* 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.
109+
* Added in prototype.constructor definitions to every class (thanks darkoverlordofdata)
107110

108111

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

123128

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

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

270276
Beyond version 1.2
271277

build/phaser.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ declare module Phaser {
212212
add(child: any): any;
213213
addAt(child: any, index: number): any;
214214
getAt(index: number): any;
215-
create(x: number, y: number, key: string, frame: string, exists?: boolean): any;
215+
create(x: number, y: number, key: string, frame?: any, exists?: boolean): Phaser.Sprite;
216216
swap(child1: any, child2: any): boolean;
217217
bringToTop(child: any): any;
218218
getIndex(child: any): number;

examples/games/breakout.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ function gameOver () {
135135

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

138-
introText.content = "Game Over!";
138+
introText.content = 'Game Over!';
139139
introText.visible = true;
140140

141141
}
@@ -154,7 +154,7 @@ function ballHitBrick (_ball, _brick) {
154154
// New level starts
155155
score += 1000;
156156
scoreText.content = 'score: ' + score;
157-
introText = '- Next Level -';
157+
introText.content = '- Next Level -';
158158

159159
// Let's move the ball back to the paddle
160160
ballOnPaddle = true;

examples/tweens/tween relative.js

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
2+
var game = new Phaser.Game(800, 600, Phaser.CANVAS, 'phaser-example', { preload: preload, create: create, render: render });
3+
4+
function preload() {
5+
6+
game.load.image('phaser', 'assets/sprites/phaser1.png');
7+
game.load.spritesheet('arrows', 'assets/sprites/arrows.png', 23, 31);
8+
9+
}
10+
11+
var arrowStart;
12+
var arrowEnd;
13+
var sprite;
14+
15+
function create() {
16+
17+
game.stage.backgroundColor = '#2384e7';
18+
19+
arrowStart = game.add.sprite(100, 100, 'arrows', 0);
20+
21+
arrowEnd = game.add.sprite(400, 100, 'arrows', 1);
22+
23+
sprite = game.add.sprite(100, 164, 'phaser');
24+
sprite.inputEnabled = true;
25+
26+
sprite.events.onInputDown.add(move, this);
27+
28+
}
29+
30+
function move() {
31+
32+
if (sprite.x === 100)
33+
{
34+
// Here you'll notice we are using a relative value for the tween.
35+
// You can specify a number as a string with either + or - at the start of it.
36+
// When the tween starts it will take the sprites current X value and add +300 to it.
37+
38+
game.add.tween(sprite).to( { x: '+300' }, 2000, Phaser.Easing.Linear.None, true);
39+
}
40+
else if (sprite.x === 400)
41+
{
42+
game.add.tween(sprite).to( { x: '-300' }, 2000, Phaser.Easing.Linear.None, true);
43+
}
44+
45+
}
46+
47+
function render() {
48+
49+
if (sprite.x === 100 || sprite.x === 400)
50+
{
51+
game.debug.renderText('Click sprite to tween', 32, 32);
52+
}
53+
54+
game.debug.renderText('x: ' + arrowStart.x, arrowStart.x, arrowStart.y - 4);
55+
game.debug.renderText('x: ' + arrowEnd.x, arrowEnd.x, arrowEnd.y - 4);
56+
57+
}

examples/wip/tween-relative.js

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
2+
var game = new Phaser.Game(800, 600, Phaser.CANVAS, 'phaser-example', { preload: preload, create: create, render: render });
3+
4+
function preload() {
5+
6+
game.load.image('phaser', 'assets/sprites/phaser1.png');
7+
game.load.spritesheet('arrows', 'assets/sprites/arrows.png', 23, 31);
8+
9+
}
10+
11+
var arrowStart;
12+
var arrowEnd;
13+
var sprite;
14+
15+
function create() {
16+
17+
game.stage.backgroundColor = '#2384e7';
18+
19+
arrowStart = game.add.sprite(100, 100, 'arrows', 0);
20+
21+
arrowEnd = game.add.sprite(400, 100, 'arrows', 1);
22+
23+
sprite = game.add.sprite(100, 164, 'phaser');
24+
sprite.inputEnabled = true;
25+
26+
sprite.events.onInputDown.add(move, this);
27+
28+
}
29+
30+
function move() {
31+
32+
if (sprite.x === 100)
33+
{
34+
// Here you'll notice we are using a relative value for the tween.
35+
// You can specify a number as a string with either + or - at the start of it.
36+
// When the tween starts it will take the sprites current X value and add +300 to it.
37+
38+
game.add.tween(sprite).to( { x: '+300' }, 2000, Phaser.Easing.Linear.None, true);
39+
}
40+
else if (sprite.x === 400)
41+
{
42+
game.add.tween(sprite).to( { x: '-300' }, 2000, Phaser.Easing.Linear.None, true);
43+
}
44+
45+
}
46+
47+
function render() {
48+
49+
if (sprite.x === 100 || sprite.x === 400)
50+
{
51+
game.debug.renderText('Click sprite to tween', 32, 32);
52+
}
53+
54+
game.debug.renderText('x: ' + arrowStart.x, arrowStart.x, arrowStart.y - 4);
55+
game.debug.renderText('x: ' + arrowEnd.x, arrowEnd.x, arrowEnd.y - 4);
56+
57+
}

src/animation/Animation.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,8 @@ Phaser.Animation.prototype = {
328328

329329
};
330330

331+
Phaser.Animation.prototype.constructor = Phaser.Animation;
332+
331333
/**
332334
* @name Phaser.Animation#paused
333335
* @property {boolean} paused - Gets and sets the paused state of this Animation.

src/animation/AnimationManager.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,8 @@ Phaser.AnimationManager.prototype = {
311311

312312
};
313313

314+
Phaser.AnimationManager.prototype.constructor = Phaser.AnimationManager;
315+
314316
/**
315317
* @name Phaser.AnimationManager#frameData
316318
* @property {Phaser.FrameData} frameData - The current animations FrameData.

src/animation/Frame.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,3 +158,5 @@ Phaser.Frame.prototype = {
158158
}
159159

160160
};
161+
162+
Phaser.Frame.prototype.constructor = Phaser.Frame;

src/animation/FrameData.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,8 @@ Phaser.FrameData.prototype = {
223223

224224
};
225225

226+
Phaser.FrameData.prototype.constructor = Phaser.FrameData;
227+
226228
/**
227229
* @name Phaser.FrameData#total
228230
* @property {number} total - The total number of frames in this FrameData set.

src/core/Camera.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,8 @@ Phaser.Camera.prototype = {
322322

323323
};
324324

325+
Phaser.Camera.prototype.constructor = Phaser.Camera;
326+
325327
/**
326328
* The Cameras x coordinate. This value is automatically clamped if it falls outside of the World bounds.
327329
* @name Phaser.Camera#x

0 commit comments

Comments
 (0)