From c7200108e83c8000bb552878227c4ad7f777ae51 Mon Sep 17 00:00:00 2001 From: Richard Davey Date: Tue, 1 Aug 2017 21:56:17 +0100 Subject: [PATCH] generateFrameNumbers and generateFrameNames updated They both now take a frames property in the config which allows you to define the sequence of frames in the animation, rather than just sequentially as before. --- .../manager/components/GenerateFrameNames.js | 42 ++++++++++++++----- .../components/GenerateFrameNumbers.js | 39 ++++++++++++----- v3/src/checksum.js | 2 +- 3 files changed, 60 insertions(+), 23 deletions(-) diff --git a/v3/src/animation/manager/components/GenerateFrameNames.js b/v3/src/animation/manager/components/GenerateFrameNames.js index 63ea2f677..d66a80f4f 100644 --- a/v3/src/animation/manager/components/GenerateFrameNames.js +++ b/v3/src/animation/manager/components/GenerateFrameNames.js @@ -8,12 +8,8 @@ var GenerateFrameNames = function (key, config) var end = GetValue(config, 'end', 0); var suffix = GetValue(config, 'suffix', ''); var zeroPad = GetValue(config, 'zeroPad', 0); - var out = GetValue(config, 'framesArray', []); - - var diff = (start < end) ? 1 : -1; - - // Adjust because we use i !== end in the for loop - end += diff; + var out = GetValue(config, 'outputArray', []); + var frames = GetValue(config, 'frames', false); var texture = this.textureManager.get(key); @@ -22,13 +18,37 @@ var GenerateFrameNames = function (key, config) return out; } - for (var i = start; i !== end; i += diff) - { - var frame = prefix + Pad(i, zeroPad, '0', 1) + suffix; + var diff = (start < end) ? 1 : -1; - if (texture.has(frame)) + // Adjust because we use i !== end in the for loop + end += diff; + + var i; + var frame; + + // Have they provided their own custom frame sequence array? + if (Array.isArray(frames)) + { + for (i = 0; i < frames.length; i++) { - out.push({ key: key, frame: frame }); + frame = prefix + Pad(frames[i], zeroPad, '0', 1) + suffix; + + if (texture.has(frame)) + { + out.push({ key: key, frame: frame }); + } + } + } + else + { + for (i = start; i !== end; i += diff) + { + frame = prefix + Pad(i, zeroPad, '0', 1) + suffix; + + if (texture.has(frame)) + { + out.push({ key: key, frame: frame }); + } } } diff --git a/v3/src/animation/manager/components/GenerateFrameNumbers.js b/v3/src/animation/manager/components/GenerateFrameNumbers.js index ea852e94b..7fb5ab5ce 100644 --- a/v3/src/animation/manager/components/GenerateFrameNumbers.js +++ b/v3/src/animation/manager/components/GenerateFrameNumbers.js @@ -5,7 +5,8 @@ var GenerateFrameNumbers = function (key, config) var startFrame = GetValue(config, 'start', 0); var endFrame = GetValue(config, 'end', -1); var firstFrame = GetValue(config, 'first', false); - var out = GetValue(config, 'framesArray', []); + var out = GetValue(config, 'outputArray', []); + var frames = GetValue(config, 'frames', false); var texture = this.textureManager.get(key); @@ -14,23 +15,39 @@ var GenerateFrameNumbers = function (key, config) return out; } - // No endFrame then see if we can get it - - if (endFrame === -1) - { - endFrame = texture.frameTotal; - } - if (firstFrame && texture.has(firstFrame)) { out.push({ key: key, frame: firstFrame }); } - for (var i = startFrame; i <= endFrame; i++) + var i; + + // Have they provided their own custom frame sequence array? + if (Array.isArray(frames)) { - if (texture.has(i)) + for (i = 0; i < frames.length; i++) { - out.push({ key: key, frame: i }); + if (texture.has(frames[i])) + { + out.push({ key: key, frame: frames[i] }); + } + } + } + else + { + // No endFrame then see if we can get it + + if (endFrame === -1) + { + endFrame = texture.frameTotal; + } + + for (i = startFrame; i <= endFrame; i++) + { + if (texture.has(i)) + { + out.push({ key: key, frame: i }); + } } } diff --git a/v3/src/checksum.js b/v3/src/checksum.js index ba6ac76b8..1ad09d21d 100644 --- a/v3/src/checksum.js +++ b/v3/src/checksum.js @@ -1,4 +1,4 @@ var CHECKSUM = { -build: 'e6190010-76d1-11e7-bdd9-f146bb3b0102' +build: 'a2b2b8a0-76fb-11e7-8281-5f266fa7c1f9' }; module.exports = CHECKSUM; \ No newline at end of file