mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-11-27 17:45:40 -05:00
Minor fixes
Making sure LayerAdapter doesn't wait for ThangType to load the image more than once. LayerAdapter skips rendering if there's a prerendered sprite sheet whose image is not loaded.
This commit is contained in:
parent
305cffb5ea
commit
b77626b8ee
2 changed files with 9 additions and 3 deletions
|
@ -179,7 +179,8 @@ module.exports = LayerAdapter = class LayerAdapter extends CocoClass
|
|||
@listenToOnce(thangType, 'raster-image-loaded', @somethingLoaded)
|
||||
@numThingsLoading++
|
||||
else if prerenderedSpriteSheet = thangType.getPrerenderedSpriteSheetToLoad()
|
||||
prerenderedSpriteSheet.loadImage()
|
||||
startedLoading = prerenderedSpriteSheet.loadImage()
|
||||
return if not startedLoading
|
||||
@listenToOnce(prerenderedSpriteSheet, 'image-loaded', -> @somethingLoaded(thangType))
|
||||
@numThingsLoading++
|
||||
|
||||
|
@ -353,6 +354,8 @@ module.exports = LayerAdapter = class LayerAdapter extends CocoClass
|
|||
|
||||
renderSegmentedThangType: (thangType, colorConfig, actionNames, spriteSheetBuilder) ->
|
||||
prerenderedSpriteSheet = thangType.getPrerenderedSpriteSheet(colorConfig, 'segmented')
|
||||
if prerenderedSpriteSheet and not prerenderedSpriteSheet.loadedImage
|
||||
return
|
||||
containersToRender = thangType.getContainersForActions(actionNames)
|
||||
spriteBuilder = new SpriteBuilder(thangType, {colorConfig: colorConfig})
|
||||
for containerGlobalName in containersToRender
|
||||
|
@ -377,6 +380,8 @@ module.exports = LayerAdapter = class LayerAdapter extends CocoClass
|
|||
prerenderedSpriteSheet = thangType.getPrerenderedSpriteSheet(colorConfig, 'singular')
|
||||
prerenderedFramesMap = {}
|
||||
if prerenderedSpriteSheet
|
||||
if not prerenderedSpriteSheet.loadedImage
|
||||
return
|
||||
scale = @resolutionFactor / (prerenderedSpriteSheet.get('resolutionFactor') or 1)
|
||||
for frame, i in prerenderedSpriteSheet.spriteSheet._frames
|
||||
sprite = new createjs.Sprite(prerenderedSpriteSheet.spriteSheet)
|
||||
|
|
|
@ -541,8 +541,8 @@ class PrerenderedSpriteSheet extends CocoModel
|
|||
@className: 'PrerenderedSpriteSheet'
|
||||
|
||||
loadImage: ->
|
||||
return if @loadingImage or @loadedImage
|
||||
return unless imageURL = @get('image')
|
||||
return false if @loadingImage or @loadedImage
|
||||
return false unless imageURL = @get('image')
|
||||
@image = $("<img src='/file/#{imageURL}' />")
|
||||
@loadingImage = true
|
||||
@image.one('load', =>
|
||||
|
@ -554,6 +554,7 @@ class PrerenderedSpriteSheet extends CocoModel
|
|||
@loadingImage = false
|
||||
@trigger('image-load-error', @)
|
||||
)
|
||||
return true
|
||||
|
||||
buildSpriteSheet: ->
|
||||
@spriteSheet = new createjs.SpriteSheet({
|
||||
|
|
Loading…
Reference in a new issue