Skip to content

Commit 90e9edb

Browse files
committed
Updated TileSprite so it just directly extends the Pixi original. This means no input events or body for a TileSprite.
Removed un-needed stuff from Graphics. Removed un-used events. Made docs in StateManager more clear re: shutdown (phaserjs#410)
1 parent 30fbbec commit 90e9edb

4 files changed

Lines changed: 16 additions & 138 deletions

File tree

src/core/StateManager.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -203,11 +203,12 @@ Phaser.StateManager.prototype = {
203203
},
204204

205205
/**
206-
* Start the given state
206+
* Start the given State. If a State is already running then State.shutDown will be called (if it exists) before switching to the new State.
207+
*
207208
* @method Phaser.StateManager#start
208209
* @param {string} key - The key of the state you want to start.
209-
* @param {boolean} [clearWorld] - clear everything in the world? (Default to true)
210-
* @param {boolean} [clearCache] - clear asset cache? (Default to false and ONLY available when clearWorld=true)
210+
* @param {boolean} [clearWorld=true] - Clear everything in the world? This clears the World display list fully (but not the Stage, so if you've added your own objects to the Stage they will need managing directly)
211+
* @param {boolean} [clearCache=false] - Clear the Game.Cache? This purges out all loaded assets. The default is false and you must have clearWorld=true if you want to clearCache as well.
211212
*/
212213
start: function (key, clearWorld, clearCache) {
213214

@@ -280,7 +281,7 @@ Phaser.StateManager.prototype = {
280281
},
281282

282283
/**
283-
* Checks i a given phaser state is valid.
284+
* Checks if a given phaser state is valid.
284285
* State must exist and have at least one callback function registered..
285286
* @method Phaser.StateManager#checkState
286287
* @param {string} key - The key of the state you want to check.

src/gameobjects/Events.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,6 @@ Phaser.Events = function (sprite) {
4242
this.onAnimationComplete = null;
4343
this.onAnimationLoop = null;
4444

45-
this.onBeginContact = null;
46-
this.onEndContact = null;
47-
4845
};
4946

5047
Phaser.Events.prototype = {

src/gameobjects/Graphics.js

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -68,12 +68,3 @@ Phaser.Graphics.prototype.drawPolygon = function (poly) {
6868
this.lineTo(poly.points[0].x, poly.points[0].y);
6969

7070
}
71-
72-
/**
73-
* Indicates the rotation of the Button in degrees, from its original orientation. Values from 0 to 180 represent clockwise rotation; values from 0 to -180 represent counterclockwise rotation.
74-
* Values outside this range are added to or subtracted from 360 to obtain a value within the range. For example, the statement player.angle = 450 is the same as player.angle = 90.
75-
* If you wish to work in radians instead of degrees use the rotation property instead. Working in radians is also a little faster as it doesn't have to convert the angle.
76-
*
77-
* @name Phaser.Button#angle
78-
* @property {number} angle - The angle of this Button in degrees.
79-
*/

src/gameobjects/TileSprite.js

Lines changed: 11 additions & 122 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,16 @@
55
*/
66

77
/**
8-
* A TileSprite is a Sprite whos texture is set to repeat and can be scrolled. As it scrolls the texture repeats (wraps) on the edges.
9-
* @class Phaser.Tilemap
10-
* @extends Phaser.Sprite
8+
* A TileSprite is a Sprite that has a repeating texture. The texture can be scrolled and scaled and will automatically wrap on the edges as it does so.
9+
* Please note that TileSprites have no input handler or physics bodies.
10+
*
11+
* @class Phaser.TileSprite
1112
* @constructor
1213
* @param {Phaser.Game} game - Current game instance.
13-
* @param {number} x - X position of the new tileSprite.
14-
* @param {number} y - Y position of the new tileSprite.
15-
* @param {number} width - the width of the tilesprite.
16-
* @param {number} height - the height of the tilesprite.
14+
* @param {number} [x=0] - X position of the new tileSprite.
15+
* @param {number} [y=0] - Y position of the new tileSprite.
16+
* @param {number} [width=256] - the width of the tilesprite.
17+
* @param {number} [height=256] - the height of the tilesprite.
1718
* @param {string|Phaser.RenderTexture|PIXI.Texture} key - This is the image or texture used by the Sprite during rendering. It can be a string which is a reference to the Cache entry, or an instance of a RenderTexture or PIXI.Texture.
1819
*/
1920
Phaser.TileSprite = function (game, x, y, width, height, key) {
@@ -24,8 +25,6 @@ Phaser.TileSprite = function (game, x, y, width, height, key) {
2425
height = height || 256;
2526
key = key || null;
2627

27-
Phaser.Sprite.call(this, game, x, y, key);
28-
2928
/**
3029
* @property {PIXI.Texture} texture - The texture that the sprite renders with.
3130
*/
@@ -39,120 +38,10 @@ Phaser.TileSprite = function (game, x, y, width, height, key) {
3938
*/
4039
this.type = Phaser.TILESPRITE;
4140

42-
/**
43-
* @property {Phaser.Point} tileScale - The scaling of the image that is being tiled.
44-
*/
45-
this.tileScale = new Phaser.Point(1, 1);
46-
47-
/**
48-
* @property {Phaser.Point} tilePosition - The offset position of the image that is being tiled.
49-
*/
50-
this.tilePosition = new Phaser.Point(0, 0);
51-
52-
this.body.width = width;
53-
this.body.height = height;
41+
this.position.x = x;
42+
this.position.y = y;
5443

5544
};
5645

57-
Phaser.TileSprite.prototype = Phaser.Utils.extend(true, PIXI.TilingSprite.prototype, Phaser.Sprite.prototype);
46+
Phaser.TileSprite.prototype = Object.create(PIXI.TilingSprite.prototype);
5847
Phaser.TileSprite.prototype.constructor = Phaser.TileSprite;
59-
60-
/**
61-
* Indicates the rotation of the Sprite, in degrees, from its original orientation. Values from 0 to 180 represent clockwise rotation; values from 0 to -180 represent counterclockwise rotation.
62-
* Values outside this range are added to or subtracted from 360 to obtain a value within the range. For example, the statement player.angle = 450 is the same as player.angle = 90.
63-
* If you wish to work in radians instead of degrees use the property Sprite.rotation instead.
64-
* @name Phaser.TileSprite#angle
65-
* @property {number} angle - Gets or sets the Sprites angle of rotation in degrees.
66-
*/
67-
Object.defineProperty(Phaser.TileSprite.prototype, 'angle', {
68-
69-
get: function() {
70-
return Phaser.Math.wrapAngle(Phaser.Math.radToDeg(this.rotation));
71-
},
72-
73-
set: function(value) {
74-
this.rotation = Phaser.Math.degToRad(Phaser.Math.wrapAngle(value));
75-
}
76-
77-
});
78-
79-
/**
80-
* @name Phaser.TileSprite#frame
81-
* @property {number} frame - Gets or sets the current frame index and updates the Texture Cache for display.
82-
*/
83-
Object.defineProperty(Phaser.TileSprite.prototype, "frame", {
84-
85-
get: function () {
86-
return this.animations.frame;
87-
},
88-
89-
set: function (value) {
90-
this.animations.frame = value;
91-
}
92-
93-
});
94-
95-
/**
96-
* @name Phaser.TileSprite#frameName
97-
* @property {string} frameName - Gets or sets the current frame name and updates the Texture Cache for display.
98-
*/
99-
Object.defineProperty(Phaser.TileSprite.prototype, "frameName", {
100-
101-
get: function () {
102-
return this.animations.frameName;
103-
},
104-
105-
set: function (value) {
106-
this.animations.frameName = value;
107-
}
108-
109-
});
110-
111-
/**
112-
* @name Phaser.TileSprite#inCamera
113-
* @property {boolean} inCamera - Is this sprite visible to the camera or not?
114-
* @readonly
115-
*/
116-
Object.defineProperty(Phaser.TileSprite.prototype, "inCamera", {
117-
118-
get: function () {
119-
return this._cache.cameraVisible;
120-
}
121-
122-
});
123-
124-
/**
125-
* By default a Sprite won't process any input events at all. By setting inputEnabled to true the Phaser.InputHandler is
126-
* activated for this Sprite instance and it will then start to process click/touch events and more.
127-
*
128-
* @name Phaser.TileSprite#inputEnabled
129-
* @property {boolean} inputEnabled - Set to true to allow this Sprite to receive input events, otherwise false.
130-
*/
131-
Object.defineProperty(Phaser.TileSprite.prototype, "inputEnabled", {
132-
133-
get: function () {
134-
135-
return (this.input.enabled);
136-
137-
},
138-
139-
set: function (value) {
140-
141-
if (value)
142-
{
143-
if (this.input.enabled === false)
144-
{
145-
this.input.start();
146-
}
147-
}
148-
else
149-
{
150-
if (this.input.enabled)
151-
{
152-
this.input.stop();
153-
}
154-
}
155-
156-
}
157-
158-
});

0 commit comments

Comments
 (0)