Class: DXOpal::Input::Touch

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

Overview

Represents a touch

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id, x, y) ⇒ Touch

Returns a new instance of Touch.



275
276
277
278
279
280
# File 'lib/dxopal/input.rb', line 275

def initialize(id, x, y)
  @id = id
  _move(x, y)
  @_released_at = nil
  @data = {}
end

Instance Attribute Details

#_released_atObject (readonly)

Returns the value of attribute _released_at.



281
282
283
# File 'lib/dxopal/input.rb', line 281

def _released_at
  @_released_at
end

#dataObject (readonly)

Returns the value of attribute data.



281
282
283
# File 'lib/dxopal/input.rb', line 281

def data
  @data
end

#idObject (readonly)

Returns the value of attribute id.



281
282
283
# File 'lib/dxopal/input.rb', line 281

def id
  @id
end

#xObject (readonly)

Returns the value of attribute x.



281
282
283
# File 'lib/dxopal/input.rb', line 281

def x
  @x
end

#yObject (readonly)

Returns the value of attribute y.



281
282
283
# File 'lib/dxopal/input.rb', line 281

def y
  @y
end

Instance Method Details

#_move(x, y) ⇒ Object



293
294
295
296
# File 'lib/dxopal/input.rb', line 293

def _move(x, y)
  @x = x
  @y = y
end

#_released(tick) ⇒ Object



298
299
300
# File 'lib/dxopal/input.rb', line 298

def _released(tick)
  @_released_at = tick
end

#inspectObject



288
289
290
291
# File 'lib/dxopal/input.rb', line 288

def inspect
  rel = (released_at ? " released_at=#{released_at}" : "")
  "#<DXOpal::Touch id=#{id} x=#{x} y=#{y} data=#{data.inspect}#{rel}>"
end

#released?Boolean

Return true if this touch is released in the last tick

Returns:

  • (Boolean)


284
285
286
# File 'lib/dxopal/input.rb', line 284

def released?
  !!@_released_at
end