Class: GGLib::DeltaCursor
- Inherits:
-
Object
- Object
- GGLib::DeltaCursor
- Defined in:
- lib/mouse.rb
Instance Attribute Summary collapse
-
#img ⇒ Object
readonly
Returns the value of attribute img.
-
#imgObj ⇒ Object
readonly
Returns the value of attribute imgObj.
-
#visible ⇒ Object
Returns the value of attribute visible.
Instance Method Summary collapse
- #draw ⇒ Object
-
#forceVisible(visible = true) ⇒ Object
Forces the cursor to remain visible until unforceVisible is called.
-
#initialize(img, visible = true) ⇒ DeltaCursor
constructor
A new instance of DeltaCursor.
-
#toggleVisible ⇒ Object
If the cursor is currently invisible, makes it visible.
-
#unforceVisible ⇒ Object
Allows the cursor to be made invisible via toggleVisible or visible=.
-
#visible? ⇒ Boolean
Returns true if the cursor is currently visible, false otherwise.
-
#x ⇒ Object
Returns the x-axis distance shifted from the center since the last call to draw.
-
#y ⇒ Object
Returns the y-axis distance shifted from the center since the last call to draw.
Constructor Details
#initialize(img, visible = true) ⇒ DeltaCursor
Returns a new instance of DeltaCursor.
102 103 104 105 106 107 108 109 110 111 |
# File 'lib/mouse.rb', line 102 def initialize(img,visible=true) @img=img @visible=visible @imgObj=Gosu::Image.new($window,img,true) @forced=false @centerx = ($window.width/2).floor @centery = ($window.height/2).floor @ax = 0 @ay = 0 end |
Instance Attribute Details
#img ⇒ Object (readonly)
Returns the value of attribute img.
101 102 103 |
# File 'lib/mouse.rb', line 101 def img @img end |
#imgObj ⇒ Object (readonly)
Returns the value of attribute imgObj.
101 102 103 |
# File 'lib/mouse.rb', line 101 def imgObj @imgObj end |
#visible ⇒ Object
Returns the value of attribute visible.
101 102 103 |
# File 'lib/mouse.rb', line 101 def visible @visible end |
Instance Method Details
#draw ⇒ Object
143 144 145 146 147 148 149 150 151 |
# File 'lib/mouse.rb', line 143 def draw @ax = $window.mouse_x @ay = $window.mouse_y $window.mouse_x = @centerx $window.mouse_y = @centery if @visible @imgObj.draw(@centerx, @centery,ZOrder::Cursor) end end |
#forceVisible(visible = true) ⇒ Object
Forces the cursor to remain visible until unforceVisible is called.
119 120 121 122 |
# File 'lib/mouse.rb', line 119 def forceVisible(visible=true) @forced=true @visible=visible end |
#toggleVisible ⇒ Object
If the cursor is currently invisible, makes it visible. If the cursor is currently visible, makes it invisible. Subject to the constraints of forceVisible.
113 114 115 116 117 |
# File 'lib/mouse.rb', line 113 def toggleVisible if not @forced @visible=!@visible end end |
#unforceVisible ⇒ Object
Allows the cursor to be made invisible via toggleVisible or visible=.
124 125 126 |
# File 'lib/mouse.rb', line 124 def unforceVisible @forced=false end |
#visible? ⇒ Boolean
Returns true if the cursor is currently visible, false otherwise.
128 129 130 |
# File 'lib/mouse.rb', line 128 def visible? return visible end |
#x ⇒ Object
Returns the x-axis distance shifted from the center since the last call to draw.
136 137 138 |
# File 'lib/mouse.rb', line 136 def x @ax - @centerx end |
#y ⇒ Object
Returns the y-axis distance shifted from the center since the last call to draw.
140 141 142 |
# File 'lib/mouse.rb', line 140 def y @ay - @centery end |