Options
All
  • Public
  • Public/Protected
  • All
Menu

Allows an object to move in 4 or 8 directions, with customizable speed, accelerations and rotation.

Hierarchy

Index

Methods

  • activate(enable: boolean): void
  • De/Activate the behavior

    Parameters

    • enable: boolean

      true to enable the behavior, false to disable it

    Returns void

  • activated(): boolean
  • allowDiagonals(allow: boolean): void
  • Parameters

    • allow: boolean

    Returns void

  • diagonalsAllowed(): boolean
  • Returns boolean

  • getAcceleration(): number
  • Returns number

  • getAngle(): number
  • Returns number

  • getAngleOffset(): number
  • Returns number

  • getAngularMaxSpeed(): number
  • Returns number

  • getDeceleration(): number
  • Returns number

  • getLastStickInputAngle(): number
  • Returns number

  • getMaxSpeed(): number
  • Returns number

  • getMovementAngleOffset(): number
  • Returns number

  • getName(): string
  • getNameId(): number
  • Get the name identifier of the behavior.

    Returns number

    The behavior's name identifier.

  • getSpeed(): number
  • Returns number

  • getXVelocity(): number
  • Returns number

  • getYVelocity(): number
  • Returns number

  • ignoreDefaultControls(ignore: boolean): void
  • Parameters

    • ignore: boolean

    Returns void

  • isMovementAngleAround(degreeAngle: number, tolerance: number): boolean
  • Parameters

    • degreeAngle: number
    • tolerance: number

    Returns boolean

  • isMoving(): boolean
  • Returns boolean

  • isObjectRotated(): boolean
  • Returns boolean

  • isUsingControl(input: string): boolean
  • .

    Parameters

    • input: string

      The control to be tested [Left,Right,Up,Down,Stick].

    Returns boolean

    true if the key was used since the last doStepPreEvents call.

  • onActivate(): void
  • Reimplement this method to do extra work when the behavior is activated (after it has been deactivated, see onDeActivate).

    Returns void

  • onCreated(): void
  • Reimplement this to do extra work when the behavior is created (i.e: an object using it was created), after the object is fully initialized (so you can use this.owner without risk).

    Returns void

  • onDeActivate(): void
  • onDestroy(): void
  • This method is called when the owner of the behavior is being removed from the scene and is about to be destroyed/reused later or when the behavior is removed from an object (can happen in case of hot-reloading only. Otherwise, behaviors are just de-activated, not removed. See onDeActivate).

    Returns void

  • onObjectHotReloaded(): void
  • This method is called when the owner of the behavior was hot reloaded, so its position, angle, size can have been changed outside of events.

    Returns void

  • A hook must typically be registered by a behavior that requires this one in its onCreate function. The hook must stay forever to avoid side effects like a hooks order change. To handle deactivated behavior, the hook can check that its behavior is activated before doing anything.

    Parameters

    Returns void

  • setAcceleration(acceleration: number): void
  • Parameters

    • acceleration: number

    Returns void

  • setAngleOffset(angleOffset: number): void
  • Parameters

    • angleOffset: number

    Returns void

  • setAngularMaxSpeed(angularMaxSpeed: number): void
  • Parameters

    • angularMaxSpeed: number

    Returns void

  • setDeceleration(deceleration: number): void
  • Parameters

    • deceleration: number

    Returns void

  • setMaxSpeed(maxSpeed: number): void
  • Parameters

    • maxSpeed: number

    Returns void

  • setMovementAngleOffset(movementAngleOffset: number): void
  • Parameters

    • movementAngleOffset: number

    Returns void

  • setRotateObject(allow: boolean): void
  • Parameters

    • allow: boolean

    Returns void

  • setViewpoint(viewpoint: string, customIsometryAngle: number): void
  • Parameters

    • viewpoint: string
    • customIsometryAngle: number

    Returns void

  • setXVelocity(velocityX: number): void
  • Parameters

    • velocityX: number

    Returns void

  • setYVelocity(velocityY: number): void
  • Parameters

    • velocityY: number

    Returns void

  • simulateControl(input: string): void
  • Parameters

    • input: string

    Returns void

  • simulateDownKey(): void
  • Returns void

  • simulateLeftKey(): void
  • Returns void

  • simulateRightKey(): void
  • Returns void

  • simulateStick(stickAngle: number, stickForce: number): void
  • Parameters

    • stickAngle: number
    • stickForce: number

    Returns void

  • simulateUpKey(): void
  • Returns void

  • Called at each frame after events. Call doStepPostEvents.
    Behaviors writers: Please do not redefine this method. Redefine doStepPreEvents instead.

    Parameters

    Returns void

  • Called at each frame before events. Call doStepPreEvents.
    Behaviors writers: Please do not redefine this method. Redefine doStepPreEvents instead.

    Parameters

    Returns void

  • updateFromBehaviorData(oldBehaviorData: any, newBehaviorData: any): boolean
  • Called when the behavior must be updated using the specified behaviorData. This is the case during hot-reload, and is only called if the behavior was modified.

    Parameters

    • oldBehaviorData: any
    • newBehaviorData: any

    Returns boolean

    true if the behavior was updated, false if it could not (i.e: hot-reload is not supported).

Constructors

Properties

name: string
type: string

Generated using TypeDoc