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,
create: ->
@loadImages "layers", "active", "progress", "selected", "entities", "hud"
@loadImages "layers", "active", "progress", "selected", "entities", "hud", "actions"
@currentHoveredTile = new Tile
ready: ->

View file

@ -4,6 +4,8 @@ app.game.hud =
@position = x: 45, y: 103
@itemArrow = new AnimatedItem maxFrames: 12, image: app.images.actions, speed: 50
@resources = []
for restype, i in resTypes
@resources[restype] = new Tilelayer(
@ -37,7 +39,8 @@ app.game.hud =
switch panelusage
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'
# resources
i = 0

View file

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