1313*
1414* @class Phaser.GameObject.Sprite
1515* @constructor
16- * @extends PIXI.Sprite
17- * @extends Phaser.Component.Core
18- * @extends Phaser.Component.Angle
19- * @extends Phaser.Component.Animation
20- * @extends Phaser.Component.AutoCull
21- * @extends Phaser.Component.Bounds
22- * @extends Phaser.Component.BringToTop
23- * @extends Phaser.Component.Crop
24- * @extends Phaser.Component.Delta
25- * @extends Phaser.Component.Destroy
26- * @extends Phaser.Component.FixedToCamera
27- * @extends Phaser.Component.Health
28- * @extends Phaser.Component.InCamera
29- * @extends Phaser.Component.InputEnabled
30- * @extends Phaser.Component.InWorld
31- * @extends Phaser.Component.LifeSpan
32- * @extends Phaser.Component.LoadTexture
33- * @extends Phaser.Component.Overlap
34- * @extends Phaser.Component.PhysicsBody
35- * @extends Phaser.Component.Reset
36- * @extends Phaser.Component.ScaleMinMax
37- * @extends Phaser.Component.Smoothed
16+ * @extends Phaser.Components.BaseTransform
3817* @param {Phaser.Game } game - A reference to the currently running game.
3918* @param {number } x - The x coordinate (in world space) to position the Sprite at.
4019* @param {number } y - The y coordinate (in world space) to position the Sprite at.
4322*/
4423Phaser . GameObject . Sprite = function ( game , x , y , key , frame )
4524{
46- x = x || 0 ;
47- y = y || 0 ;
25+ this . game = game ;
26+
27+ Phaser . Component . BaseTransform . call ( this , x , y ) ;
4828
4929 /**
5030 * @property {number } type - The const type of this object.
@@ -58,56 +38,84 @@ Phaser.GameObject.Sprite = function (game, x, y, key, frame)
5838 */
5939 this . physicsType = Phaser . SPRITE ;
6040
61- PIXI . Sprite . call ( this , Phaser . Cache . DEFAULT ) ;
41+ this . name = '' ;
42+
43+ this . parent = null ;
44+
45+ this . texture = game . textures . get ( key ) ;
46+
47+ this . frame = this . texture . get ( frame ) ;
48+
49+ this . children = new Phaser . Component . Children ( this ) ;
50+
51+ // Allows you to turn off a GO from rendering, but still render its children
52+ this . skipRender = ( key === undefined ) ;
53+
54+ this . visible = true ;
6255
63- Phaser . Component . Core . init . call ( this , game , x , y , key , frame ) ;
56+ this . data = new Phaser . Component . Data ( this ) ;
6457
58+ // Temporary for now?
59+ this . alpha = 1 ;
60+ this . blendMode = Phaser . blendModes . NORMAL ;
61+ this . scaleMode = Phaser . scaleModes . DEFAULT ;
62+ this . exists = true ;
6563} ;
6664
67- Phaser . GameObject . Sprite . prototype = Object . create ( PIXI . Sprite . prototype ) ;
65+ Phaser . GameObject . Sprite . prototype = Object . create ( Phaser . Component . BaseTransform . prototype ) ;
6866Phaser . GameObject . Sprite . prototype . constructor = Phaser . GameObject . Sprite ;
6967
70- Phaser . Component . Core . install . call ( Phaser . GameObject . Sprite . prototype , [
71- 'Angle' ,
72- 'Animation' ,
73- 'AutoCull' ,
74- 'Bounds' ,
75- 'BringToTop' ,
76- 'Crop' ,
77- 'Delta' ,
78- 'Destroy' ,
79- 'FixedToCamera' ,
80- 'Health' ,
81- 'InCamera' ,
82- 'InputEnabled' ,
83- 'InWorld' ,
84- 'LifeSpan' ,
85- 'Overlap' ,
86- 'PhysicsBody' ,
87- 'Reset' ,
88- 'ScaleMinMax' ,
89- 'Smoothed'
90- ] ) ;
91-
92- Phaser . GameObject . Sprite . prototype . preUpdatePhysics = Phaser . Component . PhysicsBody . preUpdate ;
93- Phaser . GameObject . Sprite . prototype . preUpdateLifeSpan = Phaser . Component . LifeSpan . preUpdate ;
94- Phaser . GameObject . Sprite . prototype . preUpdateInWorld = Phaser . Component . InWorld . preUpdate ;
95- Phaser . GameObject . Sprite . prototype . preUpdateCore = Phaser . Component . Core . preUpdate ;
96-
9768/**
9869* Automatically called by World.preUpdate.
9970*
100- * @method
101- * @memberof Phaser.GameObject.Sprite
102- * @return {boolean } True if the Sprite was rendered, otherwise false.
71+ * @method Phaser.Sprite#preUpdate
72+ * @memberof Phaser.Sprite
10373*/
104- Phaser . GameObject . Sprite . prototype . preUpdate = function ( ) {
105-
106- if ( ! this . preUpdatePhysics ( ) || ! this . preUpdateLifeSpan ( ) || ! this . preUpdateInWorld ( ) )
107- {
108- return false ;
109- }
74+ Phaser . GameObject . Sprite . prototype . preUpdate = function ( )
75+ {
76+ // this.transform.update();
77+ } ;
11078
111- return this . preUpdateCore ( ) ;
79+ Phaser . GameObject . Sprite . prototype . update = function ( )
80+ {
81+ } ;
11282
83+ Phaser . GameObject . Sprite . prototype . postUpdate = function ( )
84+ {
11385} ;
86+
87+ Object . defineProperties ( Phaser . GameObject . Sprite . prototype , {
88+
89+ width : {
90+
91+ enumerable : true ,
92+
93+ get : function ( )
94+ {
95+ return this . transform . _scaleX * this . frame . realWidth ;
96+ } ,
97+
98+ set : function ( value )
99+ {
100+ this . scaleX = value / this . frame . realWidth ;
101+ }
102+
103+ } ,
104+
105+ height : {
106+
107+ enumerable : true ,
108+
109+ get : function ( )
110+ {
111+ return this . transform . _scaleY * this . frame . realHeight ;
112+ } ,
113+
114+ set : function ( value )
115+ {
116+ this . scaleY = value / this . frame . realHeight ;
117+ }
118+
119+ }
120+
121+ } ) ;
0 commit comments