Skip to content

Commit bca6bd6

Browse files
committed
You can now specify a defaultTextureKey for animation configurations, to avoid having it inside of every frame object.
1 parent 15825ea commit bca6bd6

2 files changed

Lines changed: 5 additions & 4 deletions

File tree

src/animations/frame/Animation.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ var Animation = new Class({
2525
this.type = 'frame';
2626

2727
// Extract all the frame data into the frames array
28-
this.frames = GetFrames(manager.textureManager, GetValue(config, 'frames', []));
28+
this.frames = GetFrames(manager.textureManager, GetValue(config, 'frames', []), GetValue(config, 'defaultTextureKey', null));
2929

3030
// The frame rate of playback in frames per second (default 24 if duration is null)
3131
this.frameRate = GetValue(config, 'frameRate', null);

src/animations/frame/inc/GetFrames.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ var GetValue = require('../../../utils/object/GetValue');
1212
*
1313
* @return {Phaser.Animations.AnimationFrame[]} [description]
1414
*/
15-
var GetFrames = function (textureManager, frames)
15+
var GetFrames = function (textureManager, frames, defaultTextureKey)
1616
{
1717
// frames: [
1818
// { key: textureKey, frame: textureFrame },
@@ -38,7 +38,8 @@ var GetFrames = function (textureManager, frames)
3838

3939
frames = [];
4040

41-
frameKeys.forEach(function (idx, value) {
41+
frameKeys.forEach(function (idx, value)
42+
{
4243
frames.push({ key: textureKey, frame: value });
4344
});
4445
}
@@ -54,7 +55,7 @@ var GetFrames = function (textureManager, frames)
5455
{
5556
var item = frames[i];
5657

57-
var key = GetValue(item, 'key', null);
58+
var key = GetValue(item, 'key', defaultTextureKey);
5859

5960
if (!key)
6061
{

0 commit comments

Comments
 (0)