@@ -3,6 +3,45 @@ var Components = require('../components');
33var GameObject = require ( '../GameObject' ) ;
44var SpriteRender = require ( './SpriteRender' ) ;
55
6+ /**
7+ * A Sprite Game Object.
8+ *
9+ * A Sprite Game Object is used for the display of both static and animated images in your game.
10+ * Sprites can have inpt events and physics bodies. They can also be tweened, tinted, scrolled
11+ * and animated.
12+ *
13+ * The main difference between a Sprite and an Image Game Object is that you cannot animate Images.
14+ * As such, Sprites take a fraction longer to process and have a larger API footprint due to the Animation
15+ * Component. If you do not require animation then you can safely use Images to replace Sprites in all cases.
16+ *
17+ * @class Sprite
18+ * @extends Phaser.GameObjects.GameObject
19+ * @memberOf Phaser.GameObjects
20+ * @constructor
21+ * @since 3.0.0
22+ *
23+ * @extends Phaser.GameObjects.Components.Alpha
24+ * @extends Phaser.GameObjects.Components.Animation
25+ * @extends Phaser.GameObjects.Components.BlendMode
26+ * @extends Phaser.GameObjects.Components.Depth
27+ * @extends Phaser.GameObjects.Components.Flip
28+ * @extends Phaser.GameObjects.Components.GetBounds
29+ * @extends Phaser.GameObjects.Components.Origin
30+ * @extends Phaser.GameObjects.Components.Pipeline
31+ * @extends Phaser.GameObjects.Components.ScaleMode
32+ * @extends Phaser.GameObjects.Components.ScrollFactor
33+ * @extends Phaser.GameObjects.Components.Size
34+ * @extends Phaser.GameObjects.Components.Texture
35+ * @extends Phaser.GameObjects.Components.Tint
36+ * @extends Phaser.GameObjects.Components.Transform
37+ * @extends Phaser.GameObjects.Components.Visible
38+ *
39+ * @param {Phaser.Scene } scene - The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time.
40+ * @param {number } x - The horizontal position of this Game Object in the world.
41+ * @param {number } y - The vertical position of this Game Object in the world.
42+ * @param {string } texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager.
43+ * @param {string|integer } [frame] - An optional frame from the Texture this Game Object is rendering with.
44+ */
645var Sprite = new Class ( {
746
847 Extends : GameObject ,
@@ -31,6 +70,13 @@ var Sprite = new Class({
3170 {
3271 GameObject . call ( this , scene , 'Sprite' ) ;
3372
73+ /**
74+ * [description]
75+ *
76+ * @name Phaser.GameObjects.Sprite#anims
77+ * @type {[type] }
78+ * @since 3.0.0
79+ */
3480 this . anims = new Components . Animation ( this ) ;
3581
3682 this . setTexture ( texture , frame ) ;
@@ -40,18 +86,47 @@ var Sprite = new Class({
4086 this . initPipeline ( 'TextureTintPipeline' ) ;
4187 } ,
4288
89+ /**
90+ * [description]
91+ *
92+ * @method Phaser.GameObjects.Sprite#preUpdate
93+ * @since 3.0.0
94+ *
95+ * @param {number } time - [description]
96+ * @param {number } delta - [description]
97+ */
4398 preUpdate : function ( time , delta )
4499 {
45100 this . anims . update ( time , delta ) ;
46101 } ,
47102
103+ /**
104+ * [description]
105+ *
106+ * @method Phaser.GameObjects.Sprite#play
107+ * @since 3.0.0
108+ *
109+ * @param {string } key - [description]
110+ * @param {boolean } ignoreIfPlaying - [description]
111+ * @param {integer|string } startFrame - [description]
112+ *
113+ * @return {[type] } [description]
114+ */
48115 play : function ( key , ignoreIfPlaying , startFrame )
49116 {
50117 this . anims . play ( key , ignoreIfPlaying , startFrame ) ;
51118
52119 return this ;
53120 } ,
54121
122+ /**
123+ * [description]
124+ *
125+ * @method Phaser.GameObjects.Sprite#toJSON
126+ * @since 3.0.0
127+ *
128+ * @return {object } [description]
129+ */
55130 toJSON : function ( )
56131 {
57132 var data = Components . ToJSON ( this ) ;
0 commit comments