From eb5fb383960ddf1dfceb7695c4be839b404f5e0d Mon Sep 17 00:00:00 2001 From: Mike Gerwitz Date: Thu, 15 Mar 2012 23:42:28 -0400 Subject: [PATCH] Added reference to first element in circular linked list for tile frames This will both make it easy to reset an animation and help to display the first tile (when animations are disabled or for display tiles for the editor) --- lib/MapRender.js | 2 +- lib/TileMasker.js | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/MapRender.js b/lib/MapRender.js index a1b8c53..d620ce2 100644 --- a/lib/MapRender.js +++ b/lib/MapRender.js @@ -188,7 +188,7 @@ ltjs.MapRender = Class( 'MapRender', var tile = this._tiles[ tid ], ctx = ( tile.masked ) ? this._ctxObj : this._ctx; - ctx.putImageData( this._tiles[ tid ].data, x, y ); + ctx.putImageData( this._tiles[ tid ].first.data, x, y ); if ( tile.masked ) { diff --git a/lib/TileMasker.js b/lib/TileMasker.js index f37c428..aaa2c28 100644 --- a/lib/TileMasker.js +++ b/lib/TileMasker.js @@ -303,7 +303,9 @@ ltjs.TileMasker = Class( 'TileMasker', // If there is a previous frame, set the 'next' entry to its 'next' // entry to maintain the circular reference. Otherwise, set to self. - set[ id ].next = ( prev ) + // This can also be stored as the 'first' reference to permit quickly + // resetting an animation. + set[ id ].next = set[ id ].first = ( prev ) ? prev.next : set[ id ];