Class: GGLib::DeltaCursor

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

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#imgObject (readonly)

Returns the value of attribute img.



101
102
103
# File 'lib/mouse.rb', line 101

def img
  @img
end

#imgObjObject (readonly)

Returns the value of attribute imgObj.



101
102
103
# File 'lib/mouse.rb', line 101

def imgObj
  @imgObj
end

#visibleObject

Returns the value of attribute visible.



101
102
103
# File 'lib/mouse.rb', line 101

def visible
  @visible
end

Instance Method Details

#drawObject



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

#toggleVisibleObject

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

#unforceVisibleObject

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.

Returns:

  • (Boolean)


128
129
130
# File 'lib/mouse.rb', line 128

def visible?
  return visible
end

#xObject

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

#yObject

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