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 target
Object The stimulator. Returns:
true if sensor's range intersects target.- Type
- Boolean
-
init(world, opt_options=)
-
Initializes Sensor.
Parameters:
Name Type Argument Default Description world
Object An instance of World. opt_options=
Object <optional>
A map of initial properties. opt_options.type
string <optional>
'' The type of stimulus that can activate this sensor. eg. 'cold', 'heat', 'light', 'oxygen', 'food', 'predator' opt_options.targetClass
string <optional>
'Stimulus' The class of Item that can activate this sensor. eg. 'Stimulus', 'Agent', 'Sheep', 'Wolf' opt_options.behavior
string <optional>
'' The vehicle carrying the sensor will invoke this behavior when the sensor is activated. opt_options.sensitivity
number <optional>
200 The higher the sensitivity, the farther away the sensor will activate when approaching a stimulus. opt_options.width
number <optional>
7 Width. opt_options.height
number <optional>
7 Height. opt_options.offsetDistance
number <optional>
30 The distance from the center of the sensor's parent. opt_options.offsetAngle
number <optional>
0 The angle of rotation around the vehicle carrying the sensor. opt_options.opacity
number <optional>
0.75 Opacity. opt_options.target
Object <optional>
null A stimulator. opt_options.activated
boolean <optional>
false True if sensor is close enough to detect a stimulator. [opt_options.activatedColor
Array = [255, 255, 255]] The color the sensor will display when activated. opt_options.borderRadius
number <optional>
100 Border radius. opt_options.borderWidth
number <optional>
2 Border width. opt_options.borderStyle
string <optional>
'solid' Border style. [opt_options.borderColor
Array = [255, 255, 255]] Border color. opt_options.onConsume
function <optional>
null If sensor.behavior == 'CONSUME', sensor calls this function when consumption is complete. opt_options.onDestroy
function <optional>
null If sensor.behavior == 'DESTROY', sensor calls this function when target is destroyed. -
step()
-
Called every frame, step() updates the instance's properties.