Refactored SPRITE_PLACEHOLDER_RADIUS to SPRITE_PLACEHOLDER_WIDTH.

This commit is contained in:
Scott Erickson 2014-09-24 10:55:33 -07:00
parent 2cbe498f9a
commit c49f894ef2
4 changed files with 13 additions and 13 deletions

View file

@ -11,7 +11,7 @@ marked.setOptions {gfm: true, sanitize: true, smartLists: true, breaks: false}
# TODO, add C-style macro constants like this?
window.SPRITE_RESOLUTION_FACTOR = 3
window.SPRITE_PLACEHOLDER_RADIUS = 30
window.SPRITE_PLACEHOLDER_WIDTH = 60
# Prevent Ctrl/Cmd + [ / ], P, S
ctrlDefaultPrevented = [219, 221, 80, 83]

View file

@ -208,7 +208,7 @@ module.exports = LayerAdapter = class LayerAdapter extends CocoClass
return true if @willRender or not @buildAutomatically
@willRender = _.defer => @renderNewSpriteSheet()
return true
#- Rendering sprite sheets
renderNewSpriteSheet: ->
@ -223,10 +223,10 @@ module.exports = LayerAdapter = class LayerAdapter extends CocoClass
# The first frame is always the 'loading', ie placeholder, image.
placeholder = @createPlaceholder()
dimension = @resolutionFactor*SPRITE_PLACEHOLDER_RADIUS*2
dimension = @resolutionFactor * SPRITE_PLACEHOLDER_WIDTH
placeholder.setBounds(0, 0, dimension, dimension)
builder.addFrame(placeholder)
groups = {} if NEVER_RENDER_ANYTHING
for bundleGrouping in _.values(groups)
thangType = bundleGrouping[0].thangType
@ -288,7 +288,7 @@ module.exports = LayerAdapter = class LayerAdapter extends CocoClass
g.setStrokeStyle(5)
g.beginStroke(createjs.Graphics.getRGB(64,64,64))
g.beginFill(createjs.Graphics.getRGB(64,64,64,0.7))
radius = @resolutionFactor*SPRITE_PLACEHOLDER_RADIUS
radius = @resolutionFactor * SPRITE_PLACEHOLDER_WIDTH / 2
g.drawCircle(radius, radius, radius)
new createjs.Shape(g)

View file

@ -62,8 +62,8 @@ module.exports = class SegmentedSprite extends createjs.SpriteContainer
bounds = @thangType.get('raw').containers[action.container].b
sprite.x = bounds[0]
sprite.y = bounds[1]
sprite.scaleX = bounds[2] / (SPRITE_PLACEHOLDER_RADIUS * @resolutionFactor * 2)
sprite.scaleY = bounds[3] / (SPRITE_PLACEHOLDER_RADIUS * @resolutionFactor * 2)
sprite.scaleX = bounds[2] / (SPRITE_PLACEHOLDER_WIDTH * @resolutionFactor)
sprite.scaleY = bounds[3] / (SPRITE_PLACEHOLDER_WIDTH * @resolutionFactor)
else
sprite.scaleX = sprite.scaleY = 1 / scale
@children = []
@ -125,8 +125,8 @@ module.exports = class SegmentedSprite extends createjs.SpriteContainer
bounds = @thangType.get('raw').containers[localContainer.gn].b
innerContainer.x = bounds[0]
innerContainer.y = bounds[1]
innerContainer.scaleX = bounds[2] / (SPRITE_PLACEHOLDER_RADIUS * @resolutionFactor * 2)
innerContainer.scaleY = bounds[3] / (SPRITE_PLACEHOLDER_RADIUS * @resolutionFactor * 2)
innerContainer.scaleX = bounds[2] / (SPRITE_PLACEHOLDER_WIDTH * @resolutionFactor)
innerContainer.scaleY = bounds[3] / (SPRITE_PLACEHOLDER_WIDTH * @resolutionFactor)
else
innerContainer.scaleX = innerContainer.scaleY = 1 / (@resolutionFactor * (@thangType.get('scale') or 1))
outerContainer.addChild(innerContainer)

View file

@ -36,8 +36,8 @@ module.exports = class WebGLSprite extends createjs.Sprite
@_gotoAndStop(0)
@notifyActionNeedsRender(action)
bounds = @thangType.get('raw').animations[action.animation].bounds
@scaleX = bounds[2] / (SPRITE_PLACEHOLDER_RADIUS * @resolutionFactor * 2)
@scaleY = bounds[3] / (SPRITE_PLACEHOLDER_RADIUS * @resolutionFactor * 2)
@scaleX = bounds[2] / (SPRITE_PLACEHOLDER_WIDTH * @resolutionFactor)
@scaleY = bounds[3] / (SPRITE_PLACEHOLDER_WIDTH * @resolutionFactor)
@regX = (- reg.x - bounds[0]) / @scaleX
@regY = (- reg.y - bounds[1]) / @scaleY
return
@ -57,8 +57,8 @@ module.exports = class WebGLSprite extends createjs.Sprite
@_gotoAndStop(0)
@notifyActionNeedsRender(action)
bounds = @thangType.get('raw').containers[action.container].b
@scaleX = @baseScaleX = bounds[2] / (SPRITE_PLACEHOLDER_RADIUS * @resolutionFactor * 2)
@scaleY = @baseScaleY = bounds[3] / (SPRITE_PLACEHOLDER_RADIUS * @resolutionFactor * 2)
@scaleX = @baseScaleX = bounds[2] / (SPRITE_PLACEHOLDER_WIDTH * @resolutionFactor)
@scaleY = @baseScaleY = bounds[3] / (SPRITE_PLACEHOLDER_WIDTH * @resolutionFactor)
@regX = (bounds[0] - reg.x) / @scaleX
@regY = (bounds[1] - reg.y) / @scaleY
# I don't think you can properly position the placeholder without either