代码之家  ›  专栏  ›  技术社区  ›  Geo

为什么戈苏藏着我的鼠标指针?

  •  6
  • Geo  · 技术社区  · 16 年前

    我正在使用gosu gem进行一些图形编程。问题是,当我创建一个窗口时,鼠标指针是隐藏的。我可以猜测鼠标在某个时刻的位置,我可以直观地单击,但我的用户可能不会。

    如何显示指针?

    2 回复  |  直到 14 年前
        1
  •  3
  •   Ariel H. Pillet    15 年前

    我用的是这样的东西:

    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
    
        2
  •  16
  •   Arrow    14 年前

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

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

    查看libgosu的文档

    RubyGosu rdoc Reference / Window

    推荐文章