Question

I'm doing some graphics programming using the Gosu gem. The thing is, when I create a Window my mouse pointer is hidden. I can guess where the mouse is at a certain moment, and I can intuitively click, but my users may not.

How can I show the pointer?

Was it helpful?

Solution

I'm using something like this:

class Game < Gosu::Window
  def initialize
    super 800, 600, false
    @cursor = Gosu::Image.new(self, 'media/cursor.png')
  end

  def draw
    @cursor.draw self.mouse_x, self.mouse_y, 0
  end
end

Game.new.show

OTHER TIPS

If you want to use the system cursor you can do this

class Window < Gosu::Window
  def initialize
    super 320, 240, false
  end

  def needs_cursor?
    true
  end
end

Check out the documentation at libgosu

RubyGosu rdoc Reference / Window

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top