Skip to content

Commit 6ada1ec

Browse files
author
Jeroen Reurings
committed
Merge branch 'master' of https://github.com/photonstorm/phaser
2 parents a759266 + 6d8b702 commit 6ada1ec

51 files changed

Lines changed: 559 additions & 368 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

CHANGELOG.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,15 @@
7575
* Actions.SetX has 2 new arguments: `index` and `direction`.
7676
* Actions.SetXY has 2 new arguments: `index` and `direction`.
7777
* Actions.SetY has 2 new arguments: `index` and `direction`.
78-
78+
* Line.getPointA now returns a Vector2 instead of an untyped object. It also now has an optional argument that allows you to pass a vec2 in to be populated, rather than creating a new one.
79+
* Line.getPointB now returns a Vector2 instead of an untyped object. It also now has an optional argument that allows you to pass a vec2 in to be populated, rather than creating a new one.
80+
* Rectangle.getLineA now returns a Line instead of an untyped object. It also now has an optional argument that allows you to pass a Line in to be populated, rather than creating a new one.
81+
* Rectangle.getLineB now returns a Line instead of an untyped object. It also now has an optional argument that allows you to pass a Line in to be populated, rather than creating a new one.
82+
* Rectangle.getLineC now returns a Line instead of an untyped object. It also now has an optional argument that allows you to pass a Line in to be populated, rather than creating a new one.
83+
* Rectangle.getLineD now returns a Line instead of an untyped object. It also now has an optional argument that allows you to pass a Line in to be populated, rather than creating a new one.
84+
* Triangle.getLineA now returns a Line instead of an untyped object. It also now has an optional argument that allows you to pass a Line in to be populated, rather than creating a new one.
85+
* Triangle.getLineB now returns a Line instead of an untyped object. It also now has an optional argument that allows you to pass a Line in to be populated, rather than creating a new one.
86+
* Triangle.getLineC now returns a Line instead of an untyped object. It also now has an optional argument that allows you to pass a Line in to be populated, rather than creating a new one.
7987

8088

8189

src/animations/Animation.js

Lines changed: 58 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,58 @@ var Class = require('../utils/Class');
88
var Frame = require('./AnimationFrame');
99
var GetValue = require('../utils/object/GetValue');
1010

11+
/**
12+
* @typedef {object} JSONAnimation
13+
*
14+
* @property {string} key - [description]
15+
* @property {string} type - A frame based animation (as opposed to a bone based animation)
16+
* @property {JSONAnimationFrame[]} frames - [description]
17+
* @property {integer} frameRate - The frame rate of playback in frames per second (default 24 if duration is null)
18+
* @property {integer} duration - How long the animation should play for.
19+
* @property {boolean} skipMissedFrames - Skip frames if the time lags, or always advanced anyway?
20+
* @property {integer} delay - Delay before starting playback (in seconds)
21+
* @property {integer} repeat - Number of times to repeat the animation (-1 for infinity)
22+
* @property {integer} repeatDelay - Delay before the repeat starts (in seconds)
23+
* @property {boolean} yoyo - Should the animation yoyo? (reverse back down to the start) before repeating?
24+
* @property {boolean} showOnStart - Should sprite.visible = true when the animation starts to play?
25+
* @property {boolean} hideOnComplete - Should sprite.visible = false when the animation finishes?
26+
*/
27+
28+
/**
29+
* @typedef {object} AnimationFrameConfig
30+
*
31+
* @property {string} key - [description]
32+
* @property {string|number} frame - [description]
33+
* @property {float} [duration=0] - [description]
34+
* @property {boolean} [visible] - [description]
35+
* @property {function} [onUpdate] - [description]
36+
*/
37+
38+
/**
39+
* @typedef {object} AnimationConfig // TODO 19/03/2018 fix type
40+
*
41+
* @property {AnimationFrameConfig[]} [frames] - [description]
42+
* @property {string} [defaultTextureKey=null] - [description]
43+
* @property {integer} [frameRate] - The frame rate of playback in frames per second (default 24 if duration is null)
44+
* @property {integer} [duration] - How long the animation should play for.
45+
* @property {boolean} [skipMissedFrames=true] - Skip frames if the time lags, or always advanced anyway?
46+
* @property {integer} [delay=0] - Delay before starting playback (in seconds)
47+
* @property {integer} [repeat=0] - Number of times to repeat the animation (-1 for infinity)
48+
* @property {integer} [repeatDelay=0] - Delay before the repeat starts (in seconds)
49+
* @property {boolean} [yoyo=false] - Should the animation yoyo? (reverse back down to the start) before repeating?
50+
* @property {boolean} [showOnStart=false] - Should sprite.visible = true when the animation starts to play?
51+
* @property {boolean} [hideOnComplete=false] - Should sprite.visible = false when the animation finishes?
52+
* @property {object} [callbackScope] - [description]
53+
* @property {boolean} [onStart=false] - [description]
54+
* @property {array} [onStartParams] - [description]
55+
* @property {boolean} [onRepeat=false] - [description]
56+
* @property {array} [onRepeatParams] - [description]
57+
* @property {boolean} [onUpdate=false] - [description]
58+
* @property {array} [onUpdateParams] - [description]
59+
* @property {boolean} [onComplete=false] - [description]
60+
* @property {array} [onCompleteParams] - [description]
61+
*/
62+
1163
/**
1264
* @classdesc
1365
* A Frame based Animation.
@@ -25,7 +77,7 @@ var GetValue = require('../utils/object/GetValue');
2577
*
2678
* @param {Phaser.Animations.AnimationManager} manager - [description]
2779
* @param {string} key - [description]
28-
* @param {object} config - [description]
80+
* @param {AnimationConfig} config - [description]
2981
*/
3082
var Animation = new Class({
3183

@@ -65,7 +117,7 @@ var Animation = new Class({
65117
* Extract all the frame data into the frames array
66118
*
67119
* @name Phaser.Animations.Animation#frames
68-
* @type {array}
120+
* @type {Phaser.Animations.AnimationFrame[]}
69121
* @since 3.0.0
70122
*/
71123
this.frames = this.getFrames(
@@ -290,11 +342,6 @@ var Animation = new Class({
290342
this.manager.on('resumeall', this.resume.bind(this));
291343
},
292344

293-
// config = Array of Animation config objects, like:
294-
// [
295-
// { key: 'gems', frame: 'diamond0001', [duration], [visible], [onUpdate] }
296-
// ]
297-
298345
// Add frames to the end of the animation
299346

300347
/**
@@ -303,7 +350,7 @@ var Animation = new Class({
303350
* @method Phaser.Animations.Animation#addFrame
304351
* @since 3.0.0
305352
*
306-
* @param {string|object[]} config - [description]
353+
* @param {string|AnimationFrameConfig[]} config - [description]
307354
*
308355
* @return {Phaser.Animations.Animation} This Animation object.
309356
*/
@@ -312,11 +359,6 @@ var Animation = new Class({
312359
return this.addFrameAt(this.frames.length, config);
313360
},
314361

315-
// config = Array of Animation config objects, like:
316-
// [
317-
// { key: 'gems', frame: 'diamond0001', [duration], [visible], [onUpdate] }
318-
// ]
319-
320362
// Add frame/s into the animation
321363

322364
/**
@@ -326,7 +368,7 @@ var Animation = new Class({
326368
* @since 3.0.0
327369
*
328370
* @param {integer} index - [description]
329-
* @param {string|object[]} config - [description]
371+
* @param {string|AnimationFrameConfig[]} config - [description]
330372
*
331373
* @return {Phaser.Animations.Animation} This Animation object.
332374
*/
@@ -436,20 +478,13 @@ var Animation = new Class({
436478
* @since 3.0.0
437479
*
438480
* @param {Phaser.Textures.TextureManager} textureManager - [description]
439-
* @param {string|object[]} frames - [description]
481+
* @param {string|AnimationFrameConfig[]} frames - [description]
440482
* @param {string} [defaultTextureKey] - [description]
441483
*
442484
* @return {Phaser.Animations.AnimationFrame[]} [description]
443485
*/
444486
getFrames: function (textureManager, frames, defaultTextureKey)
445487
{
446-
// frames: [
447-
// { key: textureKey, frame: textureFrame },
448-
// { key: textureKey, frame: textureFrame, duration: float },
449-
// { key: textureKey, frame: textureFrame, onUpdate: function }
450-
// { key: textureKey, frame: textureFrame, visible: boolean }
451-
// ],
452-
453488
var out = [];
454489
var prev;
455490
var animationFrame;
@@ -779,7 +814,7 @@ var Animation = new Class({
779814
* @method Phaser.Animations.Animation#toJSON
780815
* @since 3.0.0
781816
*
782-
* @return {object} [description]
817+
* @return {JSONAnimation} [description]
783818
*/
784819
toJSON: function ()
785820
{

src/animations/AnimationFrame.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,14 @@
66

77
var Class = require('../utils/Class');
88

9+
/**
10+
* @typedef {object} JSONAnimationFrame
11+
*
12+
* @property {string} key - The key of the Texture this AnimationFrame uses.
13+
* @property {string|integer} frame - The key of the Frame within the Texture that this AnimationFrame uses.
14+
* @property {number} duration - Additional time (in ms) that this frame should appear for during playback.
15+
*/
16+
917
/**
1018
* @classdesc
1119
* A single frame in an Animation sequence.
@@ -151,8 +159,8 @@ var AnimationFrame = new Class({
151159
*
152160
* @method Phaser.Animations.AnimationFrame#toJSON
153161
* @since 3.0.0
154-
*
155-
* @return {object} The AnimationFrame data.
162+
*
163+
* @return {JSONAnimationFrame} The AnimationFrame data.
156164
*/
157165
toJSON: function ()
158166
{

0 commit comments

Comments
 (0)