Class: Yeah::Mouse

Inherits:
Object
  • Object
show all
Defined in:
lib/yeah/_platform/mouse.rb

Overview

Note:

Provided by a Platform.

Mouse provides mouse input handling.

Examples:

Attack on button press within game

attack if mouse.pressed? :left

Constant Summary collapse

BUTTONS =
[:left, :middle, :right, 4, 5]

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Mouse

Returns a new instance of Mouse

Parameters:

  • options (Hash) (defaults to: {})

    for new object

Options Hash (options):

  • :ticker (Ticker)

    for one-shot input handling

  • :canvas_selector (String) — default: 'canvas'

    for canvas HTML element (applicable only to Web::Mouse)

Raises:

  • (NotImplementedError)

14
15
16
# File 'lib/yeah/_platform/mouse.rb', line 14

def initialize(options = {})
  raise NotImplementedError
end

Instance Attribute Details

#position(Integer, Integer) (readonly)

Returns position of mouse cursor

Returns:

  • ((Integer, Integer))

    position of mouse cursor


# File 'lib/yeah/_platform/mouse.rb', line 24

#xInteger (readonly)

Returns x position of mouse cursor

Returns:

  • (Integer)

    x position of mouse cursor


# File 'lib/yeah/_platform/mouse.rb', line 18

#yInteger (readonly)

Returns y position of mouse cursor

Returns:

  • (Integer)

    y position of mouse cursor


# File 'lib/yeah/_platform/mouse.rb', line 21

Instance Method Details

#pressed?(button) ⇒ true, false

Returns whether button was just pressed

Parameters:

  • button (Symbol, Numeric)

    to check

Returns:

  • (true, false)

    whether button was just pressed


# File 'lib/yeah/_platform/mouse.rb', line 31

#pressing?(button) ⇒ true, false

Returns whether button is pressed

Parameters:

  • button (Symbol, Numeric)

    to check

Returns:

  • (true, false)

    whether button is pressed


# File 'lib/yeah/_platform/mouse.rb', line 27

#released?(button) ⇒ true, false

Returns whether button was just released

Parameters:

  • button (Symbol, Numeric)

    to check

Returns:

  • (true, false)

    whether button was just released


# File 'lib/yeah/_platform/mouse.rb', line 35