mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2025-02-17 08:50:58 -05:00
Fixed some memory leaks.
This commit is contained in:
parent
4b88296265
commit
4c7d7fce03
3 changed files with 10 additions and 6 deletions
|
@ -302,7 +302,7 @@ module.exports = CocoSprite = class CocoSprite extends CocoClass
|
|||
[@imageObject.x, @imageObject.y] = [sup.x, sup.y]
|
||||
@lastPos = p1.copy?() or _.clone(p1)
|
||||
@hasMoved = true
|
||||
|
||||
|
||||
updateBaseScale: ->
|
||||
scale = 1
|
||||
scale = @thangType.get('scale') or 1 if @isRaster
|
||||
|
@ -331,9 +331,9 @@ module.exports = CocoSprite = class CocoSprite extends CocoClass
|
|||
@imageObject.scaleY *= @thangType.get('scale') ? 1
|
||||
[@lastThangWidth, @lastThangHeight] = [@thang.width, @thang.height]
|
||||
return
|
||||
|
||||
|
||||
scaleX = scaleY = 1
|
||||
|
||||
|
||||
if @thangType.get('name') in ['Arrow', 'Spear']
|
||||
# Scales the arrow so it appears longer when flying parallel to horizon.
|
||||
# To do that, we convert angle to [0, 90] (mirroring half-planes twice), then make linear function out of it:
|
||||
|
@ -791,4 +791,4 @@ module.exports = CocoSprite = class CocoSprite extends CocoClass
|
|||
p.removeChild @healthBar if p = @healthBar?.parent
|
||||
@imageObject?.off 'animationend', @playNextAction
|
||||
clearInterval @effectInterval if @effectInterval
|
||||
super()
|
||||
super()
|
||||
|
|
|
@ -161,6 +161,7 @@ module.exports = class SpriteBoss extends CocoClass
|
|||
thang = sprite.thang
|
||||
delete @sprites[sprite.thang.id]
|
||||
@spriteArray.splice @spriteArray.indexOf(sprite), 1
|
||||
@stopListening sprite
|
||||
sprite.destroy()
|
||||
sprite.thang = thang # Keep around so that we know which thang the destroyed thang was for
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@ module.exports = class ThangType extends CocoModel
|
|||
isFullyLoaded: ->
|
||||
# TODO: Come up with a better way to identify when the model doesn't have everything needed to build the sprite. ie when it's a projection without all the required data.
|
||||
return @get('actions') or @get('raster') # needs one of these two things
|
||||
|
||||
|
||||
getActions: ->
|
||||
return {} unless @isFullyLoaded()
|
||||
return @actions or @buildActions()
|
||||
|
@ -62,7 +62,9 @@ module.exports = class ThangType extends CocoModel
|
|||
@options = @fillOptions options
|
||||
key = @spriteSheetKey(@options)
|
||||
if ss = @spriteSheets[key] then return ss
|
||||
return key if @building[key]
|
||||
if @building[key]
|
||||
@options = null
|
||||
return key
|
||||
@t0 = new Date().getTime()
|
||||
@initBuild(options)
|
||||
@addGeneralFrames() unless @options.portraitOnly
|
||||
|
@ -159,6 +161,7 @@ module.exports = class ThangType extends CocoModel
|
|||
@spriteSheets[key] = spriteSheet
|
||||
delete @building[key]
|
||||
@builder = null
|
||||
@options = null
|
||||
spriteSheet
|
||||
|
||||
onBuildSpriteSheetComplete: (e, data) ->
|
||||
|
|
Loading…
Reference in a new issue