.pop
method you used deletes the last element from array. You need to test all tiles and use .delete
when 'eraser_selected'
@water.each{|tile| if tile.under_point?(mouse_x,mouse_y) then @water.delete(tile) end}
@dirts.each{|tile| if tile.under_point?(mouse_x,mouse_y) then @dirts.delete(tile) end}
@grasses.each{|tile| if tile.under_point?(mouse_x,mouse_y) then @grasses.delete(tile) end}
when 'grass_selected'
@grasses.push(tile=GrassTile.new(self))
@alltiles.push(tile)
@grasses[-1].tile_position(mouse_x, mouse_y)
>': comparison of Float with nil failed (ArgumentError)
from C:/Users/h4y4shi/gosu-tile-experiment/tileclasses.rb:22:in
under_point?'block in update'
from main.rb:63:in
each'update'
from main.rb:94:in
<main>'mouse_x > @x and mouse_x < @x + 40 and
tile_position
method sets @x_tile
instead of @x
. That's the problem: the @x
variable is nil
.
Powered by mwForum 2.29.7 © 1999-2015 Markus Wichitill