Skip to content
This repository has been archived by the owner on Jan 11, 2019. It is now read-only.

Gosu Touch

neochuky edited this page Apr 24, 2013 · 1 revision

#Gosu touch activity By now you should be able to understand how to make a game in Gosu Android. The final important matter is how to handle touch input. We will use tutorial_touch_activity.rb to show how it is done.

Since you should be already familiar with tutorial.rb, we just show you this method:

  def touch_moved(touch)
    @player.warp(touch.x, touch.y)
  end

Every time the user touches the screen this method is call. Its argument touch is a class which copies the functionalities of the Touch class from Gosu for iOs. So it has an id, x and y attributes.

Gosu Android currently supports multi-touch, so if the user touched the screen with two fingers, touch_moved will be called twice and each touch will have a different id.

Along with touch_movedwe provide the following methods:

  • touch_began(touch) is called when the user started the touch.
  • touch_ended(touch) is called when the current touch ended.
Clone this wiki locally