You can now specify a defaultTextureKey for animation configurations, to avoid having it inside of every frame object.

This commit is contained in:
Richard Davey 2018-01-12 11:09:11 +00:00
parent 15825eacb3
commit bca6bd692e
2 changed files with 5 additions and 4 deletions

View file

@ -25,7 +25,7 @@ var Animation = new Class({
this.type = 'frame'; this.type = 'frame';
// Extract all the frame data into the frames array // Extract all the frame data into the frames array
this.frames = GetFrames(manager.textureManager, GetValue(config, 'frames', [])); this.frames = GetFrames(manager.textureManager, GetValue(config, 'frames', []), GetValue(config, 'defaultTextureKey', null));
// The frame rate of playback in frames per second (default 24 if duration is null) // The frame rate of playback in frames per second (default 24 if duration is null)
this.frameRate = GetValue(config, 'frameRate', null); this.frameRate = GetValue(config, 'frameRate', null);

View file

@ -12,7 +12,7 @@ var GetValue = require('../../../utils/object/GetValue');
* *
* @return {Phaser.Animations.AnimationFrame[]} [description] * @return {Phaser.Animations.AnimationFrame[]} [description]
*/ */
var GetFrames = function (textureManager, frames) var GetFrames = function (textureManager, frames, defaultTextureKey)
{ {
// frames: [ // frames: [
// { key: textureKey, frame: textureFrame }, // { key: textureKey, frame: textureFrame },
@ -38,7 +38,8 @@ var GetFrames = function (textureManager, frames)
frames = []; frames = [];
frameKeys.forEach(function (idx, value) { frameKeys.forEach(function (idx, value)
{
frames.push({ key: textureKey, frame: value }); frames.push({ key: textureKey, frame: value });
}); });
} }
@ -54,7 +55,7 @@ var GetFrames = function (textureManager, frames)
{ {
var item = frames[i]; var item = frames[i];
var key = GetValue(item, 'key', null); var key = GetValue(item, 'key', defaultTextureKey);
if (!key) if (!key)
{ {