From fe2ced1a67fbc7288541cc1ff02ec8491d3438cf Mon Sep 17 00:00:00 2001 From: Scott Erickson Date: Fri, 7 Mar 2014 17:37:11 -0800 Subject: [PATCH] Gave the health bar a border, made it a little more high res. --- app/lib/surface/CocoSprite.coffee | 4 ++-- app/lib/surface/sprite_utils.coffee | 14 +++++++++++++- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/app/lib/surface/CocoSprite.coffee b/app/lib/surface/CocoSprite.coffee index 7c7748121..cdbde389e 100644 --- a/app/lib/surface/CocoSprite.coffee +++ b/app/lib/surface/CocoSprite.coffee @@ -328,7 +328,7 @@ module.exports = CocoSprite = class CocoSprite extends CocoClass return if @thang.health is @lastHealth @lastHealth = @thang.health healthPct = Math.max(@thang.health / @thang.maxHealth, 0) - bar.scaleX = healthPct + bar.scaleX = healthPct / bar.baseScale healthOffset = @getOffset 'aboveHead' [bar.x, bar.y] = [healthOffset.x - bar.width / 2, healthOffset.y] @@ -357,7 +357,7 @@ module.exports = CocoSprite = class CocoSprite extends CocoClass bar = @healthBar = createProgressBar(healthColor, healthOffset.y) bar.x = healthOffset.x - bar.width / 2 bar.name = 'health bar' - bar.cache 0, -bar.height / 2, bar.width, bar.height + bar.cache 0, -bar.height * bar.baseScale / 2, bar.width * bar.baseScale, bar.height * bar.baseScale @displayObject.addChild bar getActionProp: (prop, subProp, def=null) -> diff --git a/app/lib/surface/sprite_utils.coffee b/app/lib/surface/sprite_utils.coffee index 6d106e0aa..68984f370 100644 --- a/app/lib/surface/sprite_utils.coffee +++ b/app/lib/surface/sprite_utils.coffee @@ -1,16 +1,28 @@ PROG_BAR_WIDTH = 20 PROG_BAR_HEIGHT = 2 +PROG_BAR_SCALE = 2.5 +EDGE_SIZE = 0.3 module.exports.createProgressBar = createProgressBar = (color, y, width=PROG_BAR_WIDTH, height=PROG_BAR_HEIGHT) -> g = new createjs.Graphics() g.setStrokeStyle(1) + + sWidth = width * PROG_BAR_SCALE + sHeight = height * PROG_BAR_SCALE + sEdge = EDGE_SIZE * PROG_BAR_SCALE + + g.beginFill(createjs.Graphics.getRGB(0, 0, 0)) + g.drawRect(0, -sHeight/2, sWidth, sHeight, sHeight) g.beginFill(createjs.Graphics.getRGB(color...)) - g.drawRoundRect(0, -1, width, height, height) + g.drawRoundRect(sEdge, sEdge - sHeight/2, sWidth-sEdge*2, sHeight-sEdge*2, sHeight-sEdge*2) s = new createjs.Shape(g) s.x = -width / 2 s.y = y s.z = 100 + s.baseScale = PROG_BAR_SCALE + s.scaleX = 1 / PROG_BAR_SCALE + s.scaleY = 1 / PROG_BAR_SCALE s.width = width s.height = height return s