Class Pointer

java.lang.Object
nl.colorize.multimedialib.renderer.Pointer
All Implemented Interfaces:
Updatable

public class Pointer extends Object implements Updatable
Represents a pointer device, which can be a mouse, a trackpad, or touch controls, depending on the current platform and device.

Devices that support multi-touch will allow multiple pointers to be active simultaneously. In such situations the render will provide access to multiple Pointer instances that can be tracked individually, using getId() to identify each pointer.

getTimePressed()

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
     
    static final int
     
    static final int
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Resets the state of this pointer, so that it is no longer marked as being pressed or released.
     
     
     
    int
     
    float
    Returns the time this pointer has been pressed, in seconds.
    boolean
    Returns true if this pointer is currently in the pressed state, regardless of the pointer's current position.
    boolean
    isPressed(Rect bounds)
    Returns true if this pointer is currently in the pressed state and the pointer's position is currently located within the specified area.
    boolean
    Returns true if this pointer is currently in the released state, regardless of the pointer's current position.
    boolean
    isReleased(Rect bounds)
    Returns true if this pointer is currently in the released state and the pointer's position is currently located within the specified area.
    void
    setPosition(Point2D position)
     
    void
    setState(int state)
     
    void
    update(float deltaTime)
    Updates this object for the current frame.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

    • Pointer

      public Pointer(String id)
  • Method Details

    • isPressed

      public boolean isPressed()
      Returns true if this pointer is currently in the pressed state, regardless of the pointer's current position.
    • isPressed

      public boolean isPressed(Rect bounds)
      Returns true if this pointer is currently in the pressed state and the pointer's position is currently located within the specified area.
    • isReleased

      public boolean isReleased()
      Returns true if this pointer is currently in the released state, regardless of the pointer's current position.
    • isReleased

      public boolean isReleased(Rect bounds)
      Returns true if this pointer is currently in the released state and the pointer's position is currently located within the specified area.
    • getTimePressed

      public float getTimePressed()
      Returns the time this pointer has been pressed, in seconds. If this pointer is in the pressed state, this will return the time since the pressed state started. If this pointer is in the released state, this returns the time between the pointer originally being pressed and it being released. Returns zero if this pointer is in the idle state.
    • clearState

      public void clearState()
      Resets the state of this pointer, so that it is no longer marked as being pressed or released. This can be used to make certain logic "consume" the pointer, without subsequent logic during the same frame update also trying to consume the same pointer.
    • update

      public void update(float deltaTime)
      Description copied from interface: Updatable
      Updates this object for the current frame. deltaTime indicates the elapsed time since the last frame update, in seconds.
      Specified by:
      update in interface Updatable
    • getId

      public String getId()
    • getPosition

      public Point2D getPosition()
    • getState

      public int getState()
    • getPressedTimer

      public Timer getPressedTimer()
    • setPosition

      public void setPosition(Point2D position)
    • setState

      public void setState(int state)