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

如何显示指针?

有帮助吗?

解决方案

我正在使用这样的东西:

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

其他提示

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

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

  def needs_cursor?
    true
  end
end

查看libgosu的文档

RubyGosu rdoc Reference / Window

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top