Skip to content

Commit 60acef2

Browse files
committed
If Game Objects change their frame, such as with an animated Sprite, and the change goes from a previously trimmed frame to a non-trimmed (full size) one, then the previous trim values were still left active, causing it to glitch (thanks stupot)
1 parent bb8da11 commit 60acef2

6 files changed

Lines changed: 62 additions & 35 deletions

File tree

README.md

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,12 +71,23 @@ Finally the list of [community authored Phaser Tutorials](http://www.lessmilk.co
7171

7272
Version 2.1.2 - "Whitebridge" - in development
7373

74+
75+
7476
### New Features
7577

78+
79+
7680
### Updates
7781

82+
* TypeScript definitions fixes and updates (thanks @clark-stevenson @englercj)
83+
84+
85+
7886
### Bug Fixes
7987

88+
* If Game Objects change their frame, such as with an animated Sprite, and the change goes from a previously trimmed frame to a non-trimmed (full size) one, then the previous trim values were still left active, causing it to glitch (thanks stupot)
89+
90+
8091
For details about changes made in previous versions of Phaser see the full Change Log at https://github.com/photonstorm/phaser/blob/master/CHANGELOG.md
8192

8293
![div](http://phaser.io/images/div3.png)
@@ -127,11 +138,11 @@ Nice and easy :)
127138

128139
Phaser is now available on [CDNJS](http://cdnjs.com). You can include the following in your html:
129140

130-
`http://cdnjs.cloudflare.com/ajax/libs/phaser/2.1.0/phaser.min.js`
141+
`http://cdnjs.cloudflare.com/ajax/libs/phaser/2.1.2/phaser.min.js`
131142

132143
Or if you prefer you can leave the protocol off, so it works via http and https:
133144

134-
`//cdnjs.cloudflare.com/ajax/libs/phaser/2.1.0/phaser.min.js`
145+
`//cdnjs.cloudflare.com/ajax/libs/phaser/2.1.2/phaser.min.js`
135146

136147
![div](http://phaser.io/images/div1.png)
137148

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,52 @@
11

22
BasicGame.Game = function (game) {
33

4-
// When a State is added to Phaser it automatically has the following properties set on it, even if they already exist:
5-
6-
this.game; // a reference to the currently running game
7-
this.add; // used to add sprites, text, groups, etc
8-
this.camera; // a reference to the game camera
9-
this.cache; // the game cache
10-
this.input; // the global input manager (you can access this.input.keyboard, this.input.mouse, as well from it)
11-
this.load; // for preloading assets
12-
this.math; // lots of useful common math operations
13-
this.sound; // the sound manager - add a sound, play one, set-up markers, etc
14-
this.stage; // the game stage
15-
this.time; // the clock
16-
this.tweens; // the tween manager
17-
this.state; // the state manager
18-
this.world; // the game world
19-
this.particles; // the particle manager
20-
this.physics; // the physics manager
21-
this.rnd; // the repeatable random number generator
22-
23-
// You can use any of these from any function within this State.
24-
// But do consider them as being 'reserved words', i.e. don't create a property for your own game called "world" or you'll over-write the world reference.
4+
// When a State is added to Phaser it automatically has the following properties set on it, even if they already exist:
5+
6+
this.game; // a reference to the currently running game (Phaser.Game)
7+
this.add; // used to add sprites, text, groups, etc (Phaser.GameObjectFactory)
8+
this.camera; // a reference to the game camera (Phaser.Camera)
9+
this.cache; // the game cache (Phaser.Cache)
10+
this.input; // the global input manager. You can access this.input.keyboard, this.input.mouse, as well from it. (Phaser.Input)
11+
this.load; // for preloading assets (Phaser.Loader)
12+
this.math; // lots of useful common math operations (Phaser.Math)
13+
this.sound; // the sound manager - add a sound, play one, set-up markers, etc (Phaser.SoundManager)
14+
this.stage; // the game stage (Phaser.Stage)
15+
this.time; // the clock (Phaser.Time)
16+
this.tweens; // the tween manager (Phaser.TweenManager)
17+
this.state; // the state manager (Phaser.StateManager)
18+
this.world; // the game world (Phaser.World)
19+
this.particles; // the particle manager (Phaser.Particles)
20+
this.physics; // the physics manager (Phaser.Physics)
21+
this.rnd; // the repeatable random number generator (Phaser.RandomDataGenerator)
22+
23+
// You can use any of these from any function within this State.
24+
// But do consider them as being 'reserved words', i.e. don't create a property for your own game called "world" or you'll over-write the world reference.
2525

2626
};
2727

2828
BasicGame.Game.prototype = {
2929

30-
create: function () {
30+
create: function () {
3131

32-
// Honestly, just about anything could go here. It's YOUR game after all. Eat your heart out!
32+
// Honestly, just about anything could go here. It's YOUR game after all. Eat your heart out!
3333

34-
},
34+
},
3535

36-
update: function () {
36+
update: function () {
3737

38-
// Honestly, just about anything could go here. It's YOUR game after all. Eat your heart out!
38+
// Honestly, just about anything could go here. It's YOUR game after all. Eat your heart out!
3939

40-
},
40+
},
4141

42-
quitGame: function (pointer) {
42+
quitGame: function (pointer) {
4343

44-
// Here you should destroy anything you no longer need.
45-
// Stop music, delete sprites, purge caches, free resources, all that good stuff.
44+
// Here you should destroy anything you no longer need.
45+
// Stop music, delete sprites, purge caches, free resources, all that good stuff.
4646

47-
// Then let's go back to the main menu.
48-
this.state.start('MainMenu');
47+
// Then let's go back to the main menu.
48+
this.state.start('MainMenu');
4949

50-
}
50+
}
5151

5252
};

src/gameobjects/Image.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,10 @@ Phaser.Image.prototype.setFrame = function(frame) {
341341
this.texture.frame.width = frame.sourceSizeW;
342342
this.texture.frame.height = frame.sourceSizeH;
343343
}
344+
else if (!frame.trimmed && this.texture.trim)
345+
{
346+
this.texture.trim = null;
347+
}
344348

345349
if (this.cropRect)
346350
{

src/gameobjects/Rope.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -387,6 +387,10 @@ Phaser.Rope.prototype.setFrame = function(frame) {
387387
this.texture.frame.width = frame.sourceSizeW;
388388
this.texture.frame.height = frame.sourceSizeH;
389389
}
390+
else if (!frame.trimmed && this.texture.trim)
391+
{
392+
this.texture.trim = null;
393+
}
390394

391395
if (this.game.renderType === Phaser.WEBGL)
392396
{

src/gameobjects/Sprite.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -459,6 +459,10 @@ Phaser.Sprite.prototype.setFrame = function(frame) {
459459
this.texture.frame.width = frame.sourceSizeW;
460460
this.texture.frame.height = frame.sourceSizeH;
461461
}
462+
else if (!frame.trimmed && this.texture.trim)
463+
{
464+
this.texture.trim = null;
465+
}
462466

463467
if (this.cropRect)
464468
{

src/gameobjects/TileSprite.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -418,6 +418,10 @@ Phaser.TileSprite.prototype.setFrame = function(frame) {
418418
this.texture.frame.width = frame.sourceSizeW;
419419
this.texture.frame.height = frame.sourceSizeH;
420420
}
421+
else if (!frame.trimmed && this.texture.trim)
422+
{
423+
this.texture.trim = null;
424+
}
421425

422426
if (this.game.renderType === Phaser.WEBGL)
423427
{

0 commit comments

Comments
 (0)