Fixed mouseout-error
This commit is contained in:
parent
1e3828511e
commit
bf6d4ee7dc
1 changed files with 22 additions and 11 deletions
|
@ -21,21 +21,32 @@ app.game =
|
||||||
@hud.render()
|
@hud.render()
|
||||||
|
|
||||||
mousedown: (event)->
|
mousedown: (event)->
|
||||||
tile = posToTile(event.x, event.y)
|
if @isMouseInView event.x, event.y
|
||||||
tile.click(event.button)
|
tile = posToTile(event.x, event.y)
|
||||||
|
tile.click(event.button)
|
||||||
|
|
||||||
@currentSelectedTile.deselect() if @currentSelectedTile
|
@currentSelectedTile.deselect() if @currentSelectedTile
|
||||||
tile.select()
|
tile.select()
|
||||||
@currentSelectedTile = tile
|
@currentSelectedTile = tile
|
||||||
|
|
||||||
mousemove: (event)->
|
mousemove: (event)->
|
||||||
tile = posToTile(event.x, event.y)
|
if @isMouseInView event.x, event.y
|
||||||
|
tile = posToTile(event.x, event.y)
|
||||||
|
|
||||||
if tile
|
if tile
|
||||||
if tile != @currentHoveredTile
|
if tile != @currentHoveredTile
|
||||||
tile.moveIn()
|
tile.moveIn()
|
||||||
@currentHoveredTile.moveOut()
|
@currentHoveredTile.moveOut() if @currentHoveredTile
|
||||||
@currentHoveredTile = tile
|
@currentHoveredTile = tile
|
||||||
|
else
|
||||||
|
@currentHoveredTile.moveOut() if @currentHoveredTile
|
||||||
|
@currentHoveredTile = null
|
||||||
|
|
||||||
|
isMouseInView: (mouseX, mouseY) ->
|
||||||
|
if mouseX < app.width and mouseX >= 0 and mouseY < app.height and mouseY >= 0
|
||||||
|
return true
|
||||||
|
|
||||||
|
false
|
||||||
|
|
||||||
keyup: (event) ->
|
keyup: (event) ->
|
||||||
switch event.key
|
switch event.key
|
||||||
|
|
Loading…
Reference in a new issue