Construct 3 icon

Construct 3

Documentation

8 Direction behavior script interface

Ashley's avatar
Medal
Construct Team Founder
Published 14 Oct, 2019
208 words
<1 min

The I8DirectionBehaviorInstance interface derives from IBehaviorInstance to add APIs specific to the 8 direction behavior.

8 direction behavior APIs

stop()

Stop the movement, setting the speed to 0.

reverse()

Invert the direction of motion. Useful as a simple way to bounce the object off an obstacle.

simulateControl(control)

Simulate one of the movement controls being held down. Useful when isDefaultControls is disabled. The control is provided as a string and must be one of "left", "right", "up", "down".

speed

Set or get the current speed in pixels per second. Note this cannot exceed maxSpeed.

maxSpeed

Set or get the maximum speed in pixels per second.

acceleration

deceleration

Set or get the acceleration/deceleration of the movement in pixels per second per second.

vectorX

vectorY

Set or get the X and Y components of the movement in pixels per second.

isDefaultControls

A boolean indicating if the default controls (using the arrow keys) are enabled.

isIgnoringInput

A boolean indicating if input is currently being ignored. If input is ignored, pressing any of the control keys has no effect. However, unlike disabling the behavior, the object can continue to move.

isEnabled

A boolean indicating if the behavior is enabled. If disabled, the behavior no longer has any effect on the object.