tips_con_010 - spoolkitamura/nyle-doc-jp GitHub Wiki

ใƒžใ‚ฆใ‚นใŒใ‚ฏใƒชใƒƒใ‚ฏใ•ใ‚ŒใŸใ‹ใฉใ†ใ‹ใ‚’่ชฟในใ‚‹ใซใฏ๏ผŸ

mouse_down?ใƒกใ‚ฝใƒƒใƒ‰ใพใŸใฏ mouse_press?ใƒกใ‚ฝใƒƒใƒ‰ใง
ใƒžใ‚ฆใ‚นใŒๆŠผใ•ใ‚ŒใŸใ‹ใฉใ†ใ‹ใ‚’่ชฟในใ‚‹ใ“ใจใŒใงใใพใ™ใ€‚

mouse_down?ใฏใƒžใ‚ฆใ‚นใŒๆŠผใ•ใ‚Œใฆใ„ใ‚‹้–“ใฏใšใฃใจ trueใ‚’่ฟ”ใ—ใ€
mouse_press?ใฏใƒžใ‚ฆใ‚นใŒๆŠผใ•ใ‚ŒใŸ็žฌ้–“ใ ใ‘ trueใ‚’่ฟ”ใ—ใพใ™ใ€‚

[้–ข้€ฃๆƒ…ๅ ฑ]
mouse_down-
mouse_press-
mouse_release-
Appendix1-MouseButtons

 

  • ใƒžใ‚ฆใ‚นใฎๅทฆใƒœใ‚ฟใƒณใŒๆŠผใ•ใ‚Œใฆใ„ใ‚‹้–“ใ ใ‘ใ€Œ่ตคใ€ใง่กจ็คบใ™ใ‚‹
require 'nyle'

class Screen < Nyle::Screen
  def initialize
    super(200, 200, {bgcolor: :IVORY})
    @color = :BLACK
  end

  def draw
    Nyle.draw_text(40, 110, "Nyle", {color: @color, size: 50})
  end

  def update
    if Nyle.mouse_down?(MOUSE_L)
      @color = :RED
    else
      @color = :BLACK
    end
  end
end

Screen.new.show_all
Nyle.main

[ๅฎŸ่กŒ็ตๆžœ]


  • ใƒžใ‚ฆใ‚นใฎๅทฆใƒœใ‚ฟใƒณใŒๆŠผใ•ใ‚Œใ‚‹ใŸใณใซใ€Œ้ป’ใ€ใจใ€Œ่ตคใ€ใจใง่‰ฒใ‚’ๅค‰ใˆใฆ่กจ็คบใ™ใ‚‹
require 'nyle'

class Screen < Nyle::Screen
  def initialize
    super(200, 200, {bgcolor: :IVORY})
    @color = :BLACK
  end

  def draw
    Nyle.draw_text(40, 110, "Nyle", {color: @color, size: 50})
  end

  def update
    if Nyle.mouse_press?(MOUSE_L)
      if @color == :BLACK
        @color = :RED
      else
        @color = :BLACK
      end
    end
  end
end

Screen.new.show_all
Nyle.main

[ๅฎŸ่กŒ็ตๆžœ]