mirror of
https://github.com/photonstorm/phaser
synced 2025-02-18 06:58:30 +00:00
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.
This commit is contained in:
parent
24278c6f3b
commit
c7200108e8
3 changed files with 60 additions and 23 deletions
|
@ -8,12 +8,8 @@ var GenerateFrameNames = function (key, config)
|
||||||
var end = GetValue(config, 'end', 0);
|
var end = GetValue(config, 'end', 0);
|
||||||
var suffix = GetValue(config, 'suffix', '');
|
var suffix = GetValue(config, 'suffix', '');
|
||||||
var zeroPad = GetValue(config, 'zeroPad', 0);
|
var zeroPad = GetValue(config, 'zeroPad', 0);
|
||||||
var out = GetValue(config, 'framesArray', []);
|
var out = GetValue(config, 'outputArray', []);
|
||||||
|
var frames = GetValue(config, 'frames', false);
|
||||||
var diff = (start < end) ? 1 : -1;
|
|
||||||
|
|
||||||
// Adjust because we use i !== end in the for loop
|
|
||||||
end += diff;
|
|
||||||
|
|
||||||
var texture = this.textureManager.get(key);
|
var texture = this.textureManager.get(key);
|
||||||
|
|
||||||
|
@ -22,13 +18,37 @@ var GenerateFrameNames = function (key, config)
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (var i = start; i !== end; i += diff)
|
var diff = (start < end) ? 1 : -1;
|
||||||
{
|
|
||||||
var frame = prefix + Pad(i, zeroPad, '0', 1) + suffix;
|
|
||||||
|
|
||||||
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 });
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,8 @@ var GenerateFrameNumbers = function (key, config)
|
||||||
var startFrame = GetValue(config, 'start', 0);
|
var startFrame = GetValue(config, 'start', 0);
|
||||||
var endFrame = GetValue(config, 'end', -1);
|
var endFrame = GetValue(config, 'end', -1);
|
||||||
var firstFrame = GetValue(config, 'first', false);
|
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);
|
var texture = this.textureManager.get(key);
|
||||||
|
|
||||||
|
@ -14,23 +15,39 @@ var GenerateFrameNumbers = function (key, config)
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
// No endFrame then see if we can get it
|
|
||||||
|
|
||||||
if (endFrame === -1)
|
|
||||||
{
|
|
||||||
endFrame = texture.frameTotal;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (firstFrame && texture.has(firstFrame))
|
if (firstFrame && texture.has(firstFrame))
|
||||||
{
|
{
|
||||||
out.push({ key: key, frame: 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 });
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
var CHECKSUM = {
|
var CHECKSUM = {
|
||||||
build: 'e6190010-76d1-11e7-bdd9-f146bb3b0102'
|
build: 'a2b2b8a0-76fb-11e7-8281-5f266fa7c1f9'
|
||||||
};
|
};
|
||||||
module.exports = CHECKSUM;
|
module.exports = CHECKSUM;
|
Loading…
Add table
Reference in a new issue