From 6bd6b2eea2137c74fa6754a5d4c7d6aa1b505600 Mon Sep 17 00:00:00 2001 From: Scott Erickson <sderickson@gmail.com> Date: Thu, 2 Oct 2014 16:50:04 -0700 Subject: [PATCH] Tweaked when and how we shift the bounds of imported sprites. For things like Anya, especially Anya's attack, it wasn't working correctly. --- app/lib/sprites/SpriteParser.coffee | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/app/lib/sprites/SpriteParser.coffee b/app/lib/sprites/SpriteParser.coffee index ad6d74cb5..b48c58bba 100644 --- a/app/lib/sprites/SpriteParser.coffee +++ b/app/lib/sprites/SpriteParser.coffee @@ -63,7 +63,13 @@ module.exports = class SpriteParser instructions.push {t: c.t, gn: c.gn} break @addContainer {c: instructions, b: container.bounds}, container.name - for movieClip in movieClips + for movieClip, index in movieClips + if index is 0 + for bounds in movieClip.frameBounds + bounds[0] -= @width / 2 + bounds[1] -= @height / 2 + movieClip.bounds[0] -= @width / 2 + movieClip.bounds[1] -= @height / 2 localGraphics = @getGraphicsFromBlock(movieClip, source) [shapeKeys, localShapes] = @getShapesFromBlock movieClip, source localContainers = @getContainersFromMovieClip movieClip, source, true @@ -174,7 +180,7 @@ module.exports = class SpriteParser frameBoundsSource = @subSourceFromRange frameBoundsRange, source if frameBoundsSource.search(/\[rect/) is -1 # some other statement; we don't have multiframe bounds console.log 'Didn\'t have multiframe bounds for this movie clip.' - frameBounds = [nominalBounds] + frameBounds = [_.clone(nominalBounds)] else lastRect = nominalBounds frameBounds = [] @@ -192,12 +198,7 @@ module.exports = class SpriteParser bounds = [0, 0, 1, 1] # Let's try this. frameBounds.push _.clone bounds else - frameBounds = [nominalBounds] - - # Subtract half of width/height parsed from lib.properties - for bounds in frameBounds - bounds[0] -= @width / 2 - bounds[1] -= @height / 2 + frameBounds = [_.clone(nominalBounds)] functionExpressions.push {name: name, bounds: nominalBounds, frameBounds: frameBounds, expression: node.parent.parent, kind: kind} @walk ast, null, gatherFunctionExpressions