Working on HUD anim

This commit is contained in:
Ruben Müller 2014-12-07 14:02:42 +01:00
parent 0a71cdbc49
commit 29ebab4b46
4 changed files with 8 additions and 5 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 222 B

After

Width:  |  Height:  |  Size: 2.8 KiB

View file

@ -5,7 +5,7 @@ app = playground(
smoothing: false, smoothing: false,
create: -> create: ->
@loadImages "layers", "active", "progress", "selected", "entities", "hud" @loadImages "layers", "active", "progress", "selected", "entities", "hud", "actions"
@currentHoveredTile = new Tile @currentHoveredTile = new Tile
ready: -> ready: ->

View file

@ -4,6 +4,8 @@ app.game.hud =
@position = x: 45, y: 103 @position = x: 45, y: 103
@itemArrow = new AnimatedItem maxFrames: 12, image: app.images.actions, speed: 50
@resources = [] @resources = []
for restype, i in resTypes for restype, i in resTypes
@resources[restype] = new Tilelayer( @resources[restype] = new Tilelayer(
@ -37,7 +39,8 @@ app.game.hud =
switch panelusage switch panelusage
when 'entity' when 'entity'
app.layer.drawRegion app.images.entities, currentSelectedTile.entity.sprite(), 44, 102 #app.layer.drawRegion app.images.entities, currentSelectedTile.entity.sprite(), 44, 102
app.layer.drawRegion @itemArrow.image, @itemArrow.sprite(), 44, 102
when 'resources' when 'resources'
# resources # resources
i = 0 i = 0

View file

@ -1,12 +1,12 @@
class AnimatedItem class AnimatedItem
constructor: (options) -> constructor: (options) ->
{@maxFrames, @image} {@maxFrames, @image, @speed} = options
@frame = 0 @frame = 0
window.setInterval @changeAnimation, 500 window.setInterval @changeAnimation, @speed
sprite: -> sprite: ->
[@frame*8, 8, 8, 8] [@frame*8, 0, 8, 8]
changeAnimation: => changeAnimation: =>
if @frame == @maxFrames if @frame == @maxFrames