为什么Gosu隐藏我的鼠标指针?

Geo*_*Geo 6 ruby mouse graphics libgosu

我正在使用Gosu gem进行一些图形编程.问题是,当我创建一个Window时,我的鼠标指针被隐藏了.我可以猜到鼠标在某个时刻的位置,我可以直观地点击,但我的用户可能没有.

如何显示指针?

小智 17

如果要使用系统光标,可以执行此操作

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

  def needs_cursor?
    true
  end
end
Run Code Online (Sandbox Code Playgroud)

查看libgosu上的文档

RubyGosu rdoc参考/窗口


小智 6

我正在使用这样的东西:

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
Run Code Online (Sandbox Code Playgroud)