public class TouchSensor extends Part
Constructor and Description |
---|
TouchSensor(SensorPort port)
Creates a sensor instance connected to the given port.
|
Modifier and Type | Method and Description |
---|---|
void |
act()
For internal use only (overrides Actor.act()).
|
void |
addTouchListener(TouchListener listener)
Register the given TouchListener to detect press or release events.
|
boolean |
isPressed()
Polls the touch sensor and returns true, if there is a collision
with any of the collision obstacles.
|
public TouchSensor(SensorPort port)
port
- the port where the sensor is plugged-inpublic void addTouchListener(TouchListener listener)
listener
- the LightListener to register; null, to terminate any running
sensor threadpublic void act()
public boolean isPressed()