RuntimeBehavior represents a behavior being used by a RuntimeObject.

Hierarchy (view full)

Constructors

Properties

Methods

activate activated applyAngularImpulse applyForce applyForceAtCenter applyForceTowardPosition applyImpulse applyImpulseAtCenter applyImpulseTowardPosition applyTorque areObjectsColliding canCollideAgainst createShape doStepPostEvents doStepPreEvents enableLayer enableMask enableSynchronization getAngularDamping getAngularVelocityX getAngularVelocityY getAngularVelocityZ getBody getBodyLayer getDensity getFriction getGravityScale getGravityX getGravityY getGravityZ getInertiaAroundX getInertiaAroundY getInertiaAroundZ getLinearDamping getLinearVelocityLength getLinearVelocityX getLinearVelocityY getLinearVelocityZ getMass getMassCenterX getMassCenterY getMassCenterZ getName getNameId getNetworkSyncData getPhysicsPosition getPhysicsRotation getRestitution getShapeScale getWorldScale hasCollisionStartedBetween hasCollisionStoppedBetween hasCustomShapeDimension hasFixedRotation isBullet isDynamic isKinematic isStatic isSyncedOverNetwork layerEnabled maskEnabled moveObjectToPhysicsPosition moveObjectToPhysicsRotation onActivate onContactBegin onContactEnd onCreated onDeActivate onDestroy onObjectHotReloaded recreateBody setAngularDamping setAngularVelocityX setAngularVelocityY setAngularVelocityZ setBullet setDensity setFixedRotation setFriction setGravityScale setGravityX setGravityY setGravityZ setLinearDamping setLinearVelocityX setLinearVelocityY setLinearVelocityZ setRestitution setShapeScale stepPostEvents stepPreEvents updateBodyFromObject updateFromBehaviorData updateFromNetworkSyncData updateObjectFromBody usesLifecycleFunction getLayersAccordingToBodyType getMasksAccordingToBodyType getQuat getRVec3 getVec3

Constructors

Properties

angularDamping: number
bodyType: string
bodyUpdater: BodyUpdater
bullet: boolean
collisionChecker: CollisionChecker
fixedRotation: boolean
friction: number
gravityScale: number
linearDamping: number
name: string

The object owning the behavior

restitution: number
type: string
density: number
layers: number
masks: number
shape: string
shapeDimensionA: any
shapeDimensionB: any
shapeDimensionC: any
shapeOrientation: string
shapeScale: number = 1

Methods

  • 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

  • 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

  • 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

      The previous data for the behavior.

    • newBehaviorData: any

      The new data for the behavior.

    Returns boolean

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

    See

    gdjs.RuntimeBehavior#onObjectHotReloaded

  • Should return false if the behavior does not need any lifecycle function to be called. Default, hidden, "capability" behaviors set it to false. This avoids useless calls to empty lifecycle functions, which would waste CPU time (and have a sizeable impact for example when lots of static instances are living in the scene).

    Returns boolean