mirror of
https://github.com/photonstorm/phaser
synced 2024-11-25 22:20:44 +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 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 });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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 });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
var CHECKSUM = {
|
||||
build: 'e6190010-76d1-11e7-bdd9-f146bb3b0102'
|
||||
build: 'a2b2b8a0-76fb-11e7-8281-5f266fa7c1f9'
|
||||
};
|
||||
module.exports = CHECKSUM;
|
Loading…
Reference in a new issue