Working on HUD anim
This commit is contained in:
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 |
|
@ -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: ->
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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
|
||||||
|
|
Loading…
Reference in a new issue