Skip to content

Commit 04debe7

Browse files
committed
Added jsdocs
1 parent a8c0ee8 commit 04debe7

2 files changed

Lines changed: 265 additions & 0 deletions

File tree

src/animations/Animation.js

Lines changed: 172 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,27 +15,77 @@ var Animation = new Class({
1515

1616
initialize:
1717

18+
/**
19+
* [description]
20+
*
21+
* @class Animation
22+
* @memberOf Phaser.Animations.Animation
23+
* @constructor
24+
* @since 3.0.0
25+
*
26+
* @param {undefined} manager - [description]
27+
* @param {undefined} key - [description]
28+
* @param {undefined} config - [description]
29+
*/
1830
function Animation (manager, key, config)
1931
{
32+
33+
/**
34+
* [description]
35+
*
36+
* @property {Phaser.Animations.AnimationManager} manager
37+
*/
2038
this.manager = manager;
2139

40+
41+
/**
42+
* [description]
43+
*
44+
* @property {string} key
45+
*/
2246
this.key = key;
2347

2448
// A frame based animation (as opposed to a bone based animation)
49+
50+
/**
51+
* [description]
52+
*
53+
* @property {string} type
54+
* @default frame
55+
*/
2556
this.type = 'frame';
2657

2758
// Extract all the frame data into the frames array
59+
60+
/**
61+
* [description]
62+
*
63+
* @property {array} frames
64+
*/
2865
this.frames = this.getFrames(
2966
manager.textureManager,
3067
GetValue(config, 'frames', []),
3168
GetValue(config, 'defaultTextureKey', null)
3269
);
3370

3471
// The frame rate of playback in frames per second (default 24 if duration is null)
72+
73+
/**
74+
* [description]
75+
*
76+
* @property {integer} frameRate
77+
* @default 24
78+
*/
3579
this.frameRate = GetValue(config, 'frameRate', null);
3680

3781
// How long the animation should play for. If frameRate is set it overrides this value
3882
// otherwise frameRate is derived from duration
83+
84+
/**
85+
* [description]
86+
*
87+
* @property {integer} duration
88+
*/
3989
this.duration = GetValue(config, 'duration', null);
4090

4191
if (this.duration === null && this.frameRate === null)
@@ -60,49 +110,171 @@ var Animation = new Class({
60110
}
61111

62112
// ms per frame (without including frame specific modifiers)
113+
114+
/**
115+
* [description]
116+
*
117+
* @property {integer} msPerFrame
118+
*/
63119
this.msPerFrame = 1000 / this.frameRate;
64120

65121
// Skip frames if the time lags, or always advanced anyway?
122+
123+
/**
124+
* [description]
125+
*
126+
* @property {boolean} skipMissedFrames
127+
* @default false
128+
*/
66129
this.skipMissedFrames = GetValue(config, 'skipMissedFrames', true);
67130

68131
// Delay before starting playback (in seconds)
132+
133+
/**
134+
* [description]
135+
*
136+
* @property {integer} delay
137+
* @default 0
138+
*/
69139
this.delay = GetValue(config, 'delay', 0);
70140

71141
// Number of times to repeat the animation (-1 for infinity)
142+
143+
/**
144+
* [description]
145+
*
146+
* @property {integer} repeat
147+
* @default 0
148+
*/
72149
this.repeat = GetValue(config, 'repeat', 0);
73150

74151
// Delay before the repeat starts (in seconds)
152+
153+
/**
154+
* [description]
155+
*
156+
* @property {integer} repeatDelay
157+
* @default 0
158+
*/
75159
this.repeatDelay = GetValue(config, 'repeatDelay', 0);
76160

77161
// Should the animation yoyo? (reverse back down to the start) before repeating?
162+
163+
/**
164+
* [description]
165+
*
166+
* @property {boolean} yoyo
167+
* @default false
168+
*/
78169
this.yoyo = GetValue(config, 'yoyo', false);
79170

80171
// Should sprite.visible = true when the animation starts to play?
172+
173+
/**
174+
* [description]
175+
*
176+
* @property {boolean} showOnStart
177+
* @default false
178+
*/
81179
this.showOnStart = GetValue(config, 'showOnStart', false);
82180

83181
// Should sprite.visible = false when the animation finishes?
182+
183+
/**
184+
* [description]
185+
*
186+
* @property {boolean} hideOnComplete
187+
* @default false
188+
*/
84189
this.hideOnComplete = GetValue(config, 'hideOnComplete', false);
85190

86191
// Callbacks
192+
193+
/**
194+
* [description]
195+
*
196+
* @property {object} callbackScope
197+
*/
87198
this.callbackScope = GetValue(config, 'callbackScope', this);
88199

200+
201+
/**
202+
* [description]
203+
*
204+
* @property {function} onStart
205+
*/
89206
this.onStart = GetValue(config, 'onStart', false);
207+
208+
/**
209+
* [description]
210+
*
211+
* @property {array} onStartParams
212+
*/
90213
this.onStartParams = GetValue(config, 'onStartParams', []);
91214

215+
216+
/**
217+
* [description]
218+
*
219+
* @property {function} onRepeat
220+
*/
92221
this.onRepeat = GetValue(config, 'onRepeat', false);
222+
223+
/**
224+
* [description]
225+
*
226+
* @property {array} onRepeatParams
227+
*/
93228
this.onRepeatParams = GetValue(config, 'onRepeatParams', []);
94229

95230
// Called for EVERY frame of the animation.
96231
// See AnimationFrame.onUpdate for a frame specific callback.
232+
233+
/**
234+
* [description]
235+
*
236+
* @property {function} onUpdate
237+
*/
97238
this.onUpdate = GetValue(config, 'onUpdate', false);
239+
240+
/**
241+
* [description]
242+
*
243+
* @property {array} onUpdateParams
244+
*/
98245
this.onUpdateParams = GetValue(config, 'onUpdateParams', []);
99246

247+
248+
/**
249+
* [description]
250+
*
251+
* @property {function} onComplete
252+
*/
100253
this.onComplete = GetValue(config, 'onComplete', false);
254+
255+
/**
256+
* [description]
257+
*
258+
* @property {array} onCompleteParams
259+
*/
101260
this.onCompleteParams = GetValue(config, 'onCompleteParams', []);
102261

103262
// Global pause, effects all Game Objects using this Animation instance
263+
264+
/**
265+
* [description]
266+
*
267+
* @property {boolean} paused
268+
* @default false
269+
*/
104270
this.paused = false;
105271

272+
273+
/**
274+
* [description]
275+
*
276+
* @property {null} manager.on('pauseall', this.pause.bind(this))
277+
*/
106278
this.manager.on('pauseall', this.pause.bind(this));
107279
this.manager.on('resumeall', this.resume.bind(this));
108280
},

src/animations/AnimationFrame.js

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,43 +6,136 @@ var AnimationFrame = new Class({
66

77
initialize:
88

9+
/**
10+
* [description]
11+
*
12+
* @class AnimationFrame
13+
* @memberOf Phaser.Animations.AnimationFrame
14+
* @constructor
15+
* @since 3.0.0
16+
*
17+
* @param {undefined} textureKey - [description]
18+
* @param {undefined} textureFrame - [description]
19+
* @param {undefined} index - [description]
20+
* @param {undefined} frame - [description]
21+
*/
922
function AnimationFrame (textureKey, textureFrame, index, frame)
1023
{
1124
// The keys into the Texture Manager of the texture + frame this uses
25+
26+
/**
27+
* [description]
28+
*
29+
* @property {string} textureKey
30+
*/
1231
this.textureKey = textureKey;
32+
33+
/**
34+
* [description]
35+
*
36+
* @property {Phaser.Textures.Frame} textureFrame
37+
*/
1338
this.textureFrame = textureFrame;
1439

1540
// The index of this frame within the Animation.frames array
41+
42+
/**
43+
* [description]
44+
*
45+
* @property {integer} index
46+
*/
1647
this.index = index;
1748

1849
// Texture Frame
50+
51+
/**
52+
* [description]
53+
*
54+
* @property {Phaser.Textures.Frame} frame
55+
*/
1956
this.frame = frame;
2057

2158
// Read-only
59+
60+
/**
61+
* [description]
62+
*
63+
* @property {boolean} isFirst
64+
* @default false
65+
*/
2266
this.isFirst = false;
2367

2468
// Read-only
69+
70+
/**
71+
* [description]
72+
*
73+
* @property {boolean} isLast
74+
* @default false
75+
*/
2576
this.isLast = false;
2677

2778
// The frame that comes before this one in the animation (if any)
2879
// Read-only
80+
81+
/**
82+
* [description]
83+
*
84+
* @property {?[type]} prevFrame
85+
* @default null
86+
*/
2987
this.prevFrame = null;
3088

3189
// The frame that comes after this one in the animation (if any)
3290
// Read-only
91+
92+
/**
93+
* [description]
94+
*
95+
* @property {?[type]} nextFrame
96+
* @default null
97+
*/
3398
this.nextFrame = null;
3499

35100
// Additional time (in ms) this frame should appear for - added onto the msPerFrame
101+
102+
/**
103+
* [description]
104+
*
105+
* @property {number} duration
106+
* @default 0
107+
*/
36108
this.duration = 0;
37109

38110
// What % through the animation progress is this frame?
39111
// Read-only
112+
113+
/**
114+
* [description]
115+
*
116+
* @property {number} progress
117+
* @default 0
118+
*/
40119
this.progress = 0;
41120

42121
// Callback if this frame gets displayed
122+
123+
/**
124+
* [description]
125+
*
126+
* @property {?[type]} onUpdate
127+
* @default null
128+
*/
43129
this.onUpdate = null;
44130

45131
// When this frame hits, set sprite.visible to this
132+
133+
/**
134+
* [description]
135+
*
136+
* @property {boolean} setVisible
137+
* @default false
138+
*/
46139
this.setVisible = false;
47140

48141
this.visible = false;

0 commit comments

Comments
 (0)