Added some error handlers for messed up thang type configs.

This commit is contained in:
Scott Erickson 2014-01-30 16:17:41 -08:00
parent 591a8e9ab5
commit 1b75ab15db
3 changed files with 7 additions and 1 deletions

View file

@ -13,7 +13,9 @@ module.exports = class SpriteBuilder
buildMovieClip: (animationName, movieClipArgs...) -> buildMovieClip: (animationName, movieClipArgs...) ->
animData = @animationStore[animationName] animData = @animationStore[animationName]
console.log "couldn't find animData from", @animationStore, "for", animationName unless animData unless animData
console.error "couldn't find animData from", @animationStore, "for", animationName
return null
locals = {} locals = {}
_.extend locals, @buildMovieClipShapes(animData.shapes) _.extend locals, @buildMovieClipShapes(animData.shapes)
_.extend locals, @buildMovieClipContainers(animData.containers) _.extend locals, @buildMovieClipContainers(animData.containers)

View file

@ -91,6 +91,7 @@ module.exports = class ThangType extends CocoModel
for animation in @requiredRawAnimations() for animation in @requiredRawAnimations()
name = animation.animation name = animation.animation
mc = @vectorParser.buildMovieClip name mc = @vectorParser.buildMovieClip name
continue unless mc
@builder.addMovieClip mc, null, animation.scale * @options.resolutionFactor @builder.addMovieClip mc, null, animation.scale * @options.resolutionFactor
framesMap[animation.scale + "_" + name] = @builder._animations[name].frames framesMap[animation.scale + "_" + name] = @builder._animations[name].frames
@ -98,6 +99,7 @@ module.exports = class ThangType extends CocoModel
continue if name is 'portrait' continue if name is 'portrait'
scale = action.scale ? @get('scale') ? 1 scale = action.scale ? @get('scale') ? 1
frames = framesMap[scale + "_" + action.animation] frames = framesMap[scale + "_" + action.animation]
continue unless frames
frames = @mapFrames(action.frames, frames[0]) if action.frames? frames = @mapFrames(action.frames, frames[0]) if action.frames?
next = true next = true
next = action.goesTo if action.goesTo next = action.goesTo if action.goesTo
@ -108,6 +110,7 @@ module.exports = class ThangType extends CocoModel
continue if name is 'portrait' continue if name is 'portrait'
scale = @options.resolutionFactor * (action.scale or @get('scale') or 1) scale = @options.resolutionFactor * (action.scale or @get('scale') or 1)
s = @vectorParser.buildContainerFromStore(action.container) s = @vectorParser.buildContainerFromStore(action.container)
continue unless s
frame = @builder.addFrame(s, s.bounds, scale) frame = @builder.addFrame(s, s.bounds, scale)
@builder.addAnimation name, [frame], false @builder.addAnimation name, [frame], false

View file

@ -210,6 +210,7 @@ module.exports = class ThangTypeEditView extends View
showMovieClip: (animationName) -> showMovieClip: (animationName) ->
vectorParser = new SpriteBuilder(@thangType) vectorParser = new SpriteBuilder(@thangType)
movieClip = vectorParser.buildMovieClip(animationName) movieClip = vectorParser.buildMovieClip(animationName)
return unless movieClip
reg = @thangType.get('positions')?.registration reg = @thangType.get('positions')?.registration
if reg if reg
movieClip.regX = -reg.x movieClip.regX = -reg.x