ld31-space-diggers/src/speechbubble.coffee

19 lines
481 B
CoffeeScript

app.game.speechbubble =
start: ->
@sprite = [0, 0, 27, 13]
say: (text) ->
clearTimeout(@timeout) if @timeout
switch text
when 'help' then @sprite = [0, 0, 27, 13]
when 'toofar' then @sprite = [0, 13, 90, 13]
@visible = true
@timeout = window.setTimeout @hide, 1000
hide: =>
app.game.speechbubble.visible = false
render: ->
app.layer.drawRegion app.images.speechbubbles, @sprite, app.game.mouseX+5, app.game.mouseY-15 if @visible