From 7ddb97fa2277b03d9a11c35d80cb321fcb1c59b7 Mon Sep 17 00:00:00 2001 From: Scott Erickson <sderickson@gmail.com> Date: Tue, 11 Feb 2014 12:32:12 -0800 Subject: [PATCH] More memory fixes. --- app/lib/surface/Surface.coffee | 5 ++++- app/lib/world/GoalManager.coffee | 8 ++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/app/lib/surface/Surface.coffee b/app/lib/surface/Surface.coffee index 5fef799bd..fe8c95b58 100644 --- a/app/lib/surface/Surface.coffee +++ b/app/lib/surface/Surface.coffee @@ -89,7 +89,10 @@ module.exports = Surface = class Surface extends CocoClass @dimmer?.destroy() @stage.clear() @musicPlayer?.destroy() - + @stage.removeEventListener 'stagemousemove', @onMouseMove + @stage.removeEventListener 'stagemousedown', @onMouseDown + @stage.removeAllEventListeners() + setWorld: (@world) -> @worldLoaded = true @world.getFrame(Math.min(@getCurrentFrame(), @world.totalFrames - 1)).restoreState() unless @options.choosing diff --git a/app/lib/world/GoalManager.coffee b/app/lib/world/GoalManager.coffee index 12d2fbe80..c48ed7d08 100644 --- a/app/lib/world/GoalManager.coffee +++ b/app/lib/world/GoalManager.coffee @@ -46,7 +46,7 @@ module.exports = class GoalManager extends CocoClass 'world:thang-collected-item': 'onThangCollectedItem' 'world:ended': 'onWorldEnded' - onLevelRestarted: => + onLevelRestarted: -> @goals = [] @goalStates = {} @userCodeMap = {} @@ -55,12 +55,12 @@ module.exports = class GoalManager extends CocoClass # INTERFACE AND LIFETIME OVERVIEW # main instance receives goal updates from the script manager - onAddGoals: (e) => + onAddGoals: (e) -> return unless e.worldName is @world.name goals = e.goals @addGoal(goal) for goal in goals - onRemoveGoals: (e) => + onRemoveGoals: (e) -> if e.goal in @goals @goals.remove(e.goal) delete @goalStates[e.goal] @@ -88,7 +88,7 @@ module.exports = class GoalManager extends CocoClass # main instance gets them and updates their existing goal states, # passes the word along - onNewWorldCreated: (e) => + onNewWorldCreated: (e) -> @updateGoalStates(e.goalStates) if e.goalStates? @world = e.world