Skip to content

Commit

Permalink
reset() was supposed to be called on the current level (to free some …
Browse files Browse the repository at this point in the history
…memory) and not the new one….
  • Loading branch information
obiot committed Apr 30, 2012
1 parent a7a6217 commit 6581cde
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 5 deletions.
28 changes: 24 additions & 4 deletions src/level/TMXTiledMap.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,34 @@
// map type (only orthogonal format supported)
this.orientation = "";

// a canvas where to draw our map(s)
this.tileMapCanvas = null;

// tileset(s)
this.tilesets = null;

},


/**
* a dummy update function
* @private
*/
reset : function() {
// free background_image
this.background_image = null;

// reset/clear all layers
for ( var i = this.mapLayers.length; i--;) {
this.mapLayers[i].layerSurface = null;
this.mapLayers[i].layerCanvas = null;
this.mapLayers[i].layerData = null;
this.mapLayers[i].xLUT = this.yLUT = null
this.mapLayers[i].tilesets = this.tileset = null;
this.mapLayers[i].objectGroups = null;
this.mapLayers[i] = null;
};
this.initialized = false
// call parent reset fct
this.parent();
},

/**
* Load & initialize the Tile Map
* @private
Expand Down
4 changes: 3 additions & 1 deletion src/level/level.js
Original file line number Diff line number Diff line change
Expand Up @@ -768,7 +768,9 @@
me.utils.resetGUID(levelId);

// load the level
levels[levelId].reset();
if (levels[currentLevelIdx]) {
levels[currentLevelIdx].reset();
}
levels[levelId].load();

// update current level index
Expand Down

0 comments on commit 6581cde

Please sign in to comment.