Fixed some memory leaks.
This commit is contained in:
parent
4b88296265
commit
4c7d7fce03
3 changed files with 10 additions and 6 deletions
app
|
@ -302,7 +302,7 @@ module.exports = CocoSprite = class CocoSprite extends CocoClass
|
||||||
[@imageObject.x, @imageObject.y] = [sup.x, sup.y]
|
[@imageObject.x, @imageObject.y] = [sup.x, sup.y]
|
||||||
@lastPos = p1.copy?() or _.clone(p1)
|
@lastPos = p1.copy?() or _.clone(p1)
|
||||||
@hasMoved = true
|
@hasMoved = true
|
||||||
|
|
||||||
updateBaseScale: ->
|
updateBaseScale: ->
|
||||||
scale = 1
|
scale = 1
|
||||||
scale = @thangType.get('scale') or 1 if @isRaster
|
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
|
@imageObject.scaleY *= @thangType.get('scale') ? 1
|
||||||
[@lastThangWidth, @lastThangHeight] = [@thang.width, @thang.height]
|
[@lastThangWidth, @lastThangHeight] = [@thang.width, @thang.height]
|
||||||
return
|
return
|
||||||
|
|
||||||
scaleX = scaleY = 1
|
scaleX = scaleY = 1
|
||||||
|
|
||||||
if @thangType.get('name') in ['Arrow', 'Spear']
|
if @thangType.get('name') in ['Arrow', 'Spear']
|
||||||
# Scales the arrow so it appears longer when flying parallel to horizon.
|
# 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:
|
# 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
|
p.removeChild @healthBar if p = @healthBar?.parent
|
||||||
@imageObject?.off 'animationend', @playNextAction
|
@imageObject?.off 'animationend', @playNextAction
|
||||||
clearInterval @effectInterval if @effectInterval
|
clearInterval @effectInterval if @effectInterval
|
||||||
super()
|
super()
|
||||||
|
|
|
@ -161,6 +161,7 @@ module.exports = class SpriteBoss extends CocoClass
|
||||||
thang = sprite.thang
|
thang = sprite.thang
|
||||||
delete @sprites[sprite.thang.id]
|
delete @sprites[sprite.thang.id]
|
||||||
@spriteArray.splice @spriteArray.indexOf(sprite), 1
|
@spriteArray.splice @spriteArray.indexOf(sprite), 1
|
||||||
|
@stopListening sprite
|
||||||
sprite.destroy()
|
sprite.destroy()
|
||||||
sprite.thang = thang # Keep around so that we know which thang the destroyed thang was for
|
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: ->
|
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.
|
# 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
|
return @get('actions') or @get('raster') # needs one of these two things
|
||||||
|
|
||||||
getActions: ->
|
getActions: ->
|
||||||
return {} unless @isFullyLoaded()
|
return {} unless @isFullyLoaded()
|
||||||
return @actions or @buildActions()
|
return @actions or @buildActions()
|
||||||
|
@ -62,7 +62,9 @@ module.exports = class ThangType extends CocoModel
|
||||||
@options = @fillOptions options
|
@options = @fillOptions options
|
||||||
key = @spriteSheetKey(@options)
|
key = @spriteSheetKey(@options)
|
||||||
if ss = @spriteSheets[key] then return ss
|
if ss = @spriteSheets[key] then return ss
|
||||||
return key if @building[key]
|
if @building[key]
|
||||||
|
@options = null
|
||||||
|
return key
|
||||||
@t0 = new Date().getTime()
|
@t0 = new Date().getTime()
|
||||||
@initBuild(options)
|
@initBuild(options)
|
||||||
@addGeneralFrames() unless @options.portraitOnly
|
@addGeneralFrames() unless @options.portraitOnly
|
||||||
|
@ -159,6 +161,7 @@ module.exports = class ThangType extends CocoModel
|
||||||
@spriteSheets[key] = spriteSheet
|
@spriteSheets[key] = spriteSheet
|
||||||
delete @building[key]
|
delete @building[key]
|
||||||
@builder = null
|
@builder = null
|
||||||
|
@options = null
|
||||||
spriteSheet
|
spriteSheet
|
||||||
|
|
||||||
onBuildSpriteSheetComplete: (e, data) ->
|
onBuildSpriteSheetComplete: (e, data) ->
|
||||||
|
|
Reference in a new issue