mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2025-04-13 21:44:40 -04:00
Add clear timers to not have timer running in the background on home page.
This commit is contained in:
parent
cf41f6e3d0
commit
21915f358c
1 changed files with 11 additions and 1 deletions
|
@ -37,11 +37,18 @@ module.exports = class HomeView extends View
|
|||
initCanvas: =>
|
||||
@stage = new createjs.Stage($('#beginner-campaign canvas', @$el)[0])
|
||||
@createWizard -10, 2, 2.6
|
||||
@turnOnStageUpdates()
|
||||
|
||||
turnOnStageUpdates: ->
|
||||
@interval = setInterval(@updateStage, 40) unless @interval
|
||||
|
||||
turnOffStageUpdates: ->
|
||||
turnOffFunc = =>
|
||||
clearInterval @interval
|
||||
clearInterval @turnOff
|
||||
@interval = null
|
||||
@turnOff = null
|
||||
@turnOff = setInterval turnOffFunc, 2000
|
||||
|
||||
createWizard: (x=0, y=0, scale=1.0) ->
|
||||
spriteOptions = thangID: "Beginner Wizard", resolutionFactor: scale
|
||||
@wizardSprite = new WizardSprite @wizardType, spriteOptions
|
||||
|
@ -54,9 +61,11 @@ module.exports = class HomeView extends View
|
|||
@stage.update()
|
||||
|
||||
onMouseOverButton: ->
|
||||
@turnOnStageUpdates()
|
||||
@wizardSprite?.queueAction 'cast'
|
||||
|
||||
onMouseOutButton: ->
|
||||
@turnOffStageUpdates()
|
||||
@wizardSprite?.queueAction 'idle'
|
||||
|
||||
updateStage: =>
|
||||
|
@ -70,3 +79,4 @@ module.exports = class HomeView extends View
|
|||
didReappear: ->
|
||||
super()
|
||||
@turnOnStageUpdates()
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue