Solarus quests
1.6
Quest maker's reference
|
A sensor is an invisible detector that triggers something when the hero overlaps it.
This type of map entity can be declared in the map data file. It can also be created dynamically with map:create_sensor().
Unlike switches, sensors cannot be avoided by a jump. If you want the hero to be detected for sure when he enters somewhere, use a sensor rather than an invisible switch.
When a sensor is activated, the event sensor:on_activated() is called. Define that event to implement what happens: closing a door, starting a dialog, etc.
Sensors can have any size, but like all entities, their width and height must be multiples of 8 pixels. The minimum size if 16x16 pixels (the size of the hero).
A sensor is activated only if the bounding box of the hero is entirely on the sensor.
Sensors are particular map entities. Therefore, they inherit all methods from the type map entity.
See Methods of all entity types to know these methods.
None.
Events are callback methods automatically called by the engine if you define them.
Sensors are particular map entities. Therefore, they inherit all events from the type map entity.
See Events of all entity types to know these events.
The following events are specific to sensors.
Called when the hero overlaps this sensor.
The bounding box of the hero (of size 16x16 pixels) must fit entirely the sensor. This means that if the sensor has a size of 16x16, the hero and the sensor must overlap perfectly.
This event is the right place to define the action that you want your sensor to perform.
Called continuously while the hero overlaps this sensor.
Called when the hero stops overlapping this sensor.
Called when an explosion touches this sensor.