mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2025-05-02 08:53:38 -04:00
Refactored SPRITE_PLACEHOLDER_RADIUS to SPRITE_PLACEHOLDER_WIDTH.
This commit is contained in:
parent
2cbe498f9a
commit
c49f894ef2
4 changed files with 13 additions and 13 deletions
|
@ -11,7 +11,7 @@ marked.setOptions {gfm: true, sanitize: true, smartLists: true, breaks: false}
|
||||||
|
|
||||||
# TODO, add C-style macro constants like this?
|
# TODO, add C-style macro constants like this?
|
||||||
window.SPRITE_RESOLUTION_FACTOR = 3
|
window.SPRITE_RESOLUTION_FACTOR = 3
|
||||||
window.SPRITE_PLACEHOLDER_RADIUS = 30
|
window.SPRITE_PLACEHOLDER_WIDTH = 60
|
||||||
|
|
||||||
# Prevent Ctrl/Cmd + [ / ], P, S
|
# Prevent Ctrl/Cmd + [ / ], P, S
|
||||||
ctrlDefaultPrevented = [219, 221, 80, 83]
|
ctrlDefaultPrevented = [219, 221, 80, 83]
|
||||||
|
|
|
@ -208,7 +208,7 @@ module.exports = LayerAdapter = class LayerAdapter extends CocoClass
|
||||||
return true if @willRender or not @buildAutomatically
|
return true if @willRender or not @buildAutomatically
|
||||||
@willRender = _.defer => @renderNewSpriteSheet()
|
@willRender = _.defer => @renderNewSpriteSheet()
|
||||||
return true
|
return true
|
||||||
|
|
||||||
#- Rendering sprite sheets
|
#- Rendering sprite sheets
|
||||||
|
|
||||||
renderNewSpriteSheet: ->
|
renderNewSpriteSheet: ->
|
||||||
|
@ -223,10 +223,10 @@ module.exports = LayerAdapter = class LayerAdapter extends CocoClass
|
||||||
|
|
||||||
# The first frame is always the 'loading', ie placeholder, image.
|
# The first frame is always the 'loading', ie placeholder, image.
|
||||||
placeholder = @createPlaceholder()
|
placeholder = @createPlaceholder()
|
||||||
dimension = @resolutionFactor*SPRITE_PLACEHOLDER_RADIUS*2
|
dimension = @resolutionFactor * SPRITE_PLACEHOLDER_WIDTH
|
||||||
placeholder.setBounds(0, 0, dimension, dimension)
|
placeholder.setBounds(0, 0, dimension, dimension)
|
||||||
builder.addFrame(placeholder)
|
builder.addFrame(placeholder)
|
||||||
|
|
||||||
groups = {} if NEVER_RENDER_ANYTHING
|
groups = {} if NEVER_RENDER_ANYTHING
|
||||||
for bundleGrouping in _.values(groups)
|
for bundleGrouping in _.values(groups)
|
||||||
thangType = bundleGrouping[0].thangType
|
thangType = bundleGrouping[0].thangType
|
||||||
|
@ -288,7 +288,7 @@ module.exports = LayerAdapter = class LayerAdapter extends CocoClass
|
||||||
g.setStrokeStyle(5)
|
g.setStrokeStyle(5)
|
||||||
g.beginStroke(createjs.Graphics.getRGB(64,64,64))
|
g.beginStroke(createjs.Graphics.getRGB(64,64,64))
|
||||||
g.beginFill(createjs.Graphics.getRGB(64,64,64,0.7))
|
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)
|
g.drawCircle(radius, radius, radius)
|
||||||
new createjs.Shape(g)
|
new createjs.Shape(g)
|
||||||
|
|
||||||
|
|
|
@ -62,8 +62,8 @@ module.exports = class SegmentedSprite extends createjs.SpriteContainer
|
||||||
bounds = @thangType.get('raw').containers[action.container].b
|
bounds = @thangType.get('raw').containers[action.container].b
|
||||||
sprite.x = bounds[0]
|
sprite.x = bounds[0]
|
||||||
sprite.y = bounds[1]
|
sprite.y = bounds[1]
|
||||||
sprite.scaleX = bounds[2] / (SPRITE_PLACEHOLDER_RADIUS * @resolutionFactor * 2)
|
sprite.scaleX = bounds[2] / (SPRITE_PLACEHOLDER_WIDTH * @resolutionFactor)
|
||||||
sprite.scaleY = bounds[3] / (SPRITE_PLACEHOLDER_RADIUS * @resolutionFactor * 2)
|
sprite.scaleY = bounds[3] / (SPRITE_PLACEHOLDER_WIDTH * @resolutionFactor)
|
||||||
else
|
else
|
||||||
sprite.scaleX = sprite.scaleY = 1 / scale
|
sprite.scaleX = sprite.scaleY = 1 / scale
|
||||||
@children = []
|
@children = []
|
||||||
|
@ -125,8 +125,8 @@ module.exports = class SegmentedSprite extends createjs.SpriteContainer
|
||||||
bounds = @thangType.get('raw').containers[localContainer.gn].b
|
bounds = @thangType.get('raw').containers[localContainer.gn].b
|
||||||
innerContainer.x = bounds[0]
|
innerContainer.x = bounds[0]
|
||||||
innerContainer.y = bounds[1]
|
innerContainer.y = bounds[1]
|
||||||
innerContainer.scaleX = bounds[2] / (SPRITE_PLACEHOLDER_RADIUS * @resolutionFactor * 2)
|
innerContainer.scaleX = bounds[2] / (SPRITE_PLACEHOLDER_WIDTH * @resolutionFactor)
|
||||||
innerContainer.scaleY = bounds[3] / (SPRITE_PLACEHOLDER_RADIUS * @resolutionFactor * 2)
|
innerContainer.scaleY = bounds[3] / (SPRITE_PLACEHOLDER_WIDTH * @resolutionFactor)
|
||||||
else
|
else
|
||||||
innerContainer.scaleX = innerContainer.scaleY = 1 / (@resolutionFactor * (@thangType.get('scale') or 1))
|
innerContainer.scaleX = innerContainer.scaleY = 1 / (@resolutionFactor * (@thangType.get('scale') or 1))
|
||||||
outerContainer.addChild(innerContainer)
|
outerContainer.addChild(innerContainer)
|
||||||
|
|
|
@ -36,8 +36,8 @@ module.exports = class WebGLSprite extends createjs.Sprite
|
||||||
@_gotoAndStop(0)
|
@_gotoAndStop(0)
|
||||||
@notifyActionNeedsRender(action)
|
@notifyActionNeedsRender(action)
|
||||||
bounds = @thangType.get('raw').animations[action.animation].bounds
|
bounds = @thangType.get('raw').animations[action.animation].bounds
|
||||||
@scaleX = bounds[2] / (SPRITE_PLACEHOLDER_RADIUS * @resolutionFactor * 2)
|
@scaleX = bounds[2] / (SPRITE_PLACEHOLDER_WIDTH * @resolutionFactor)
|
||||||
@scaleY = bounds[3] / (SPRITE_PLACEHOLDER_RADIUS * @resolutionFactor * 2)
|
@scaleY = bounds[3] / (SPRITE_PLACEHOLDER_WIDTH * @resolutionFactor)
|
||||||
@regX = (- reg.x - bounds[0]) / @scaleX
|
@regX = (- reg.x - bounds[0]) / @scaleX
|
||||||
@regY = (- reg.y - bounds[1]) / @scaleY
|
@regY = (- reg.y - bounds[1]) / @scaleY
|
||||||
return
|
return
|
||||||
|
@ -57,8 +57,8 @@ module.exports = class WebGLSprite extends createjs.Sprite
|
||||||
@_gotoAndStop(0)
|
@_gotoAndStop(0)
|
||||||
@notifyActionNeedsRender(action)
|
@notifyActionNeedsRender(action)
|
||||||
bounds = @thangType.get('raw').containers[action.container].b
|
bounds = @thangType.get('raw').containers[action.container].b
|
||||||
@scaleX = @baseScaleX = bounds[2] / (SPRITE_PLACEHOLDER_RADIUS * @resolutionFactor * 2)
|
@scaleX = @baseScaleX = bounds[2] / (SPRITE_PLACEHOLDER_WIDTH * @resolutionFactor)
|
||||||
@scaleY = @baseScaleY = bounds[3] / (SPRITE_PLACEHOLDER_RADIUS * @resolutionFactor * 2)
|
@scaleY = @baseScaleY = bounds[3] / (SPRITE_PLACEHOLDER_WIDTH * @resolutionFactor)
|
||||||
@regX = (bounds[0] - reg.x) / @scaleX
|
@regX = (bounds[0] - reg.x) / @scaleX
|
||||||
@regY = (bounds[1] - reg.y) / @scaleY
|
@regY = (bounds[1] - reg.y) / @scaleY
|
||||||
# I don't think you can properly position the placeholder without either
|
# I don't think you can properly position the placeholder without either
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue