Window.button_down(id)
. This method is called before update and draw each frame and registers single presses of keys. If you want to use it anywhere, you can store the pressed key in some variable and make sure it resets after update/draw is done.
#put somewhere in your Gosu::Window subclass:
def button_down(id)
case id
when this
@ents[@selection].do(that)
end
end
def button_up(id)
case id
when this
@ents[@selection].stop(that)
@selection += 1
end
@selection %= @ents.size #<- to ensure @ents[@selection] never returns a nil value.
end
end
Powered by mwForum 2.29.7 © 1999-2015 Markus Wichitill