From e4e846e5f2e2616ebc9fd4fcd5811aa7972ca145 Mon Sep 17 00:00:00 2001 From: Chad Engler Date: Fri, 17 Oct 2014 07:07:09 -0700 Subject: [PATCH] fix animations for object layer items --- src/tiled/Objectlayer.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/tiled/Objectlayer.js b/src/tiled/Objectlayer.js index 388828d..82560f9 100644 --- a/src/tiled/Objectlayer.js +++ b/src/tiled/Objectlayer.js @@ -114,6 +114,7 @@ Objectlayer.prototype.spawn = function (spawnCallback) { obj; props.tileprops = {}; + props.animation = null; // gid means a sprite from a tileset texture if (o.gid) { @@ -123,6 +124,7 @@ Objectlayer.prototype.spawn = function (spawnCallback) { if (set) { props.texture = set.getTileTexture(o.gid); props.tileprops = set.getTileProperties(o.gid); + props.animation = set.getTileAnimations(o.gid); // if no hitArea then use the tileset's if available if (!props.hitArea) { @@ -228,10 +230,10 @@ Objectlayer.prototype.spawn = function (spawnCallback) { } } - if (props.animation || props.tileprops.animation) { - if (obj.animations) { - obj.animations.play(props.animation || props.tileprops.animation); - } + if (props.animation && obj.animations) { + obj.animations.copyFrameData(props.animation.data, 0); + obj.animations.add('tile', null, props.animation.rate, true).play(); + // obj.animations.play(props.animation || props.tileprops.animation); } if (typeof o.rotation === 'number') {