new Sensor(opt_options=)
Creates a new Sensor object.
Parameters:
| Name | Type | Argument | Description |
|---|---|---|---|
opt_options= |
Object |
<optional> |
A map of initial properties. |
Extends
Methods
-
_sensorActive(target) → {Boolean}
-
Checks if a sensor can detect a stimulus object. Note: Assumes target is a circle.
Parameters:
Name Type Description targetObject The stimulator. Returns:
true if sensor's range intersects target.- Type
- Boolean
-
init(world, opt_options=)
-
Initializes Sensor.
Parameters:
Name Type Argument Default Description worldObject An instance of World. opt_options=Object <optional>
A map of initial properties. opt_options.typestring <optional>
'' The type of stimulus that can activate this sensor. eg. 'cold', 'heat', 'light', 'oxygen', 'food', 'predator' opt_options.targetClassstring <optional>
'Stimulus' The class of Item that can activate this sensor. eg. 'Stimulus', 'Agent', 'Sheep', 'Wolf' opt_options.behaviorstring <optional>
'' The vehicle carrying the sensor will invoke this behavior when the sensor is activated. opt_options.sensitivitynumber <optional>
200 The higher the sensitivity, the farther away the sensor will activate when approaching a stimulus. opt_options.widthnumber <optional>
7 Width. opt_options.heightnumber <optional>
7 Height. opt_options.offsetDistancenumber <optional>
30 The distance from the center of the sensor's parent. opt_options.offsetAnglenumber <optional>
0 The angle of rotation around the vehicle carrying the sensor. opt_options.opacitynumber <optional>
0.75 Opacity. opt_options.targetObject <optional>
null A stimulator. opt_options.activatedboolean <optional>
false True if sensor is close enough to detect a stimulator. [opt_options.activatedColorArray = [255, 255, 255]] The color the sensor will display when activated. opt_options.borderRadiusnumber <optional>
100 Border radius. opt_options.borderWidthnumber <optional>
2 Border width. opt_options.borderStylestring <optional>
'solid' Border style. [opt_options.borderColorArray = [255, 255, 255]] Border color. opt_options.onConsumefunction <optional>
null If sensor.behavior == 'CONSUME', sensor calls this function when consumption is complete. opt_options.onDestroyfunction <optional>
null If sensor.behavior == 'DESTROY', sensor calls this function when target is destroyed. -
step()
-
Called every frame, step() updates the instance's properties.