21 lines
581 B
CoffeeScript
21 lines
581 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]
|
|
when 'nores' then @sprite = [0, 26, 90, 13]
|
|
when 'nosel' then @sprite = [0, 39, 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 |