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.



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

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.



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

def _released_at
  @_released_at
end

#dataObject (readonly)

Returns the value of attribute data.



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

def data
  @data
end

#idObject (readonly)

Returns the value of attribute id.



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

def id
  @id
end

#xObject (readonly)

Returns the value of attribute x.



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

def x
  @x
end

#yObject (readonly)

Returns the value of attribute y.



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

def y
  @y
end

Instance Method Details

#_move(x, y) ⇒ Object



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

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

#_released(tick) ⇒ Object



301
302
303
# File 'lib/dxopal/input.rb', line 301

def _released(tick)
  @_released_at = tick
end

#inspectObject



291
292
293
294
# File 'lib/dxopal/input.rb', line 291

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)


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

def released?
  !!@_released_at
end