Skip to content

Commit 456809e

Browse files
committed
GetFrames can now handle you setting just a string for the frames array, and it'll get all the frames from the texture for it.
1 parent 3647e28 commit 456809e

2 files changed

Lines changed: 36 additions & 12 deletions

File tree

v3/src/animation/frame/GetFrames.js

Lines changed: 35 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,34 @@ var GetFrames = function (textureManager, frames)
1010
// { key: textureKey, frame: textureFrame, visible: boolean }
1111
// ],
1212

13-
// console.table(frames);
14-
1513
var out = [];
1614
var prev;
1715
var animationFrame;
1816
var index = 1;
1917
var i;
18+
var textureKey;
19+
20+
// if frames is a string, we'll get all the frames from the texture manager as if it's a sprite sheet
21+
if (typeof frames === 'string')
22+
{
23+
textureKey = frames;
24+
25+
var texture = textureManager.get(textureKey);
26+
var frameKeys = texture.getFrameNames();
27+
28+
frames = [];
29+
30+
frameKeys.forEach(function (idx, value) {
31+
frames.push({ key: textureKey, frame: value });
32+
});
33+
}
34+
35+
// console.table(frames);
36+
37+
if (!Array.isArray(frames) || frames.length === 0)
38+
{
39+
return out;
40+
}
2041

2142
for (i = 0; i < frames.length; i++)
2243
{
@@ -63,20 +84,23 @@ var GetFrames = function (textureManager, frames)
6384
index++;
6485
}
6586

66-
animationFrame.isLast = true;
87+
if (out.length > 0)
88+
{
89+
animationFrame.isLast = true;
6790

68-
// Link them end-to-end, so they loop
69-
animationFrame.nextFrame = out[0];
91+
// Link them end-to-end, so they loop
92+
animationFrame.nextFrame = out[0];
7093

71-
out[0].prevFrame = animationFrame;
94+
out[0].prevFrame = animationFrame;
7295

73-
// Generate the progress data
96+
// Generate the progress data
7497

75-
var slice = 1 / (out.length - 1);
98+
var slice = 1 / (out.length - 1);
7699

77-
for (i = 0; i < out.length; i++)
78-
{
79-
out[i].progress = i * slice;
100+
for (i = 0; i < out.length; i++)
101+
{
102+
out[i].progress = i * slice;
103+
}
80104
}
81105

82106
return out;

v3/src/checksum.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
var CHECKSUM = {
2-
build: '2fba6110-2bb8-11e7-b7ee-51481bf3d671'
2+
build: 'b96938a0-2bc2-11e7-a9b9-e791b0b8b64d'
33
};
44
module.exports = CHECKSUM;

0 commit comments

Comments
 (0)