mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-11-24 08:08:15 -05:00
Gave the health bar a border, made it a little more high res.
This commit is contained in:
parent
8fa9c9c410
commit
fe2ced1a67
2 changed files with 15 additions and 3 deletions
|
@ -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) ->
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue