RuntimeBehavior represents a behavior being used by a RuntimeObject.

Hierarchy (view full)

Constructors

Properties

Methods

activate activated addDistanceJoint addFrictionJoint addGearJoint addMotorJoint addMouseJoint addPrismaticJoint addPulleyJoint addRevoluteJoint addRevoluteJointBetweenTwoBodies addRopeJoint addWeldJoint addWheelJoint applyAngularImpulse applyForce applyForceTowardPosition applyImpulse applyImpulseTowardPosition applyPolarForce applyPolarImpulse applyTorque areObjectsColliding b2Vec2 b2Vec2Sec createBody createShape doStepPostEvents doStepPreEvents enableLayer enableMask enablePrismaticJointLimits enablePrismaticJointMotor enableRevoluteJointLimits enableRevoluteJointMotor enableSynchronization enableWheelJointMotor getAngularDamping getAngularVelocity getBody getDensity getDistanceJointDampingRatio getDistanceJointFrequency getDistanceJointLength getFriction getFrictionJointMaxForce getFrictionJointMaxTorque getGearJointFirstJoint getGearJointRatio getGearJointSecondJoint getGravityScale getGravityX getGravityY getInertia getJointFirstAnchorX getJointFirstAnchorY getJointReactionForce getJointReactionTorque getJointSecondAnchorX getJointSecondAnchorY getLinearDamping getLinearVelocityAngle getLinearVelocityLength getLinearVelocityX getLinearVelocityY getMass getMassCenterX getMassCenterY getMotorJointAngularOffset getMotorJointCorrectionFactor getMotorJointMaxForce getMotorJointMaxTorque getMotorJointOffsetX getMotorJointOffsetY getMouseJointDampingRatio getMouseJointFrequency getMouseJointMaxForce getMouseJointTargetX getMouseJointTargetY getName getNameId getNetworkSyncData getPolygon getPrismaticJointAxisAngle getPrismaticJointMaxMotorForce getPrismaticJointMaxTranslation getPrismaticJointMinTranslation getPrismaticJointMotorForce getPrismaticJointMotorSpeed getPrismaticJointReferenceAngle getPrismaticJointSpeed getPrismaticJointTranslation getPulleyJointFirstGroundAnchorX getPulleyJointFirstGroundAnchorY getPulleyJointFirstLength getPulleyJointRatio getPulleyJointSecondGroundAnchorX getPulleyJointSecondGroundAnchorY getPulleyJointSecondLength getRestitution getRevoluteJointAngle getRevoluteJointMaxAngle getRevoluteJointMaxMotorTorque getRevoluteJointMinAngle getRevoluteJointMotorSpeed getRevoluteJointMotorTorque getRevoluteJointReferenceAngle getRevoluteJointSpeed getRopeJointMaxLength getShapeScale getTimeScale getWeldJointDampingRatio getWeldJointFrequency getWeldJointReferenceAngle getWheelJointAxisAngle getWheelJointDampingRatio getWheelJointFrequency getWheelJointMaxMotorTorque getWheelJointMotorSpeed getWheelJointMotorTorque getWheelJointSpeed getWheelJointTranslation getWorldScale hasCollisionStartedBetween hasCollisionStoppedBetween hasFixedRotation isBullet isDynamic isJointFirstObject isJointSecondObject isKinematic isLinearVelocityAngleAround isPolygonConvex isPrismaticJointLimitsEnabled isPrismaticJointMotorEnabled isRevoluteJointLimitsEnabled isRevoluteJointMotorEnabled isSleeping isSleepingAllowed isStatic isSyncedOverNetwork isWheelJointMotorEnabled layerEnabled maskEnabled onActivate onContactBegin onContactEnd onCreated onDeActivate onDestroy onObjectHotReloaded recreateShape removeJoint setAngularDamping setAngularVelocity setBullet setDensity setDistanceJointDampingRatio setDistanceJointFrequency setDistanceJointLength setDynamic setFixedRotation setFriction setFrictionJointMaxForce setFrictionJointMaxTorque setGearJointRatio setGravity setGravityScale setKinematic setLinearDamping setLinearVelocityAngle setLinearVelocityX setLinearVelocityY setMotorJointAngularOffset setMotorJointCorrectionFactor setMotorJointMaxForce setMotorJointMaxTorque setMotorJointOffset setMouseJointDampingRatio setMouseJointFrequency setMouseJointMaxForce setMouseJointTarget setPrismaticJointLimits setPrismaticJointMaxMotorForce setPrismaticJointMotorSpeed setRestitution setRevoluteJointLimits setRevoluteJointMaxMotorTorque setRevoluteJointMotorSpeed setRopeJointMaxLength setShapeScale setSleepingAllowed setStatic setTimeScale setTimeScaleFromObject setWeldJointDampingRatio setWeldJointFrequency setWheelJointDampingRatio setWheelJointFrequency setWheelJointMaxMotorTorque setWheelJointMotorSpeed stepPostEvents stepPreEvents updateBodyFromObject updateFromBehaviorData updateFromNetworkSyncData updateObjectFromBody usesLifecycleFunction

Constructors

Properties

angularDamping: number
bodyType: string
bullet: boolean
canSleep: boolean
collisionTest: ((object1, object2, behaviorName) => boolean) = Physics2RuntimeBehavior.areObjectsColliding

Type declaration

    • (object1, object2, behaviorName): boolean
    • Parameters

      Returns boolean

Deprecated

Prefer using Physics2RuntimeBehavior.areObjectsColliding.

contactsEndedThisFrame: Physics2RuntimeBehavior[]

Array containing the end of contacts reported by onContactEnd. The array is updated each time the method onContactEnd is called by the listener, which can be called at any time. This array is cleared just before stepping the world.

contactsStartedThisFrame: Physics2RuntimeBehavior[]

Array containing the beginning of contacts reported by onContactBegin. Each contact should be unique to avoid recording glitches where the object loses and regain contact between two frames. The array is updated each time the method onContactBegin is called by the listener, which is only called when stepping the world i.e. in the first preEvent called by a physics behavior. This array is cleared just before stepping the world.

currentContacts: Physics2RuntimeBehavior[]

Array containing the exact current contacts with the objects. It is updated each time the methods onContactBegin and onContactEnd are called by the contact listener.

density: number
destroyedDuringFrameLogic: boolean
fixedRotation: boolean
friction: number
gravityScale: number
layers: number
linearDamping: number
masks: number
name: string

The object owning the behavior

polygon: null | Polygon
polygonOrigin: string
restitution: number
shape: string
shapeDimensionA: any
shapeDimensionB: any
shapeOffsetX: number
shapeOffsetY: number
shapeScale: number = 1
type: string

Methods

  • Parameters

    • x1: number
    • y1: number
    • other: null | RuntimeObject
    • x2: number
    • y2: number
    • axisAngle: number
    • referenceAngle: number
    • enableLimit: boolean
    • lowerTranslation: number
    • upperTranslation: number
    • enableMotor: boolean
    • motorSpeed: number
    • maxMotorForce: number
    • collideConnected: boolean
    • variable: Variable

    Returns void

  • Parameters

    • x1: number
    • y1: number
    • other: null | RuntimeObject
    • x2: number
    • y2: number
    • groundX1: number
    • groundY1: number
    • groundX2: number
    • groundY2: number
    • lengthA: number
    • lengthB: number
    • ratio: number
    • collideConnected: boolean
    • variable: Variable

    Returns void

  • Parameters

    • x: number
    • y: number
    • enableLimit: boolean
    • referenceAngle: number
    • lowerAngle: number
    • upperAngle: number
    • enableMotor: boolean
    • motorSpeed: number
    • maxMotorTorque: number
    • variable: Variable

    Returns void

  • Parameters

    • x1: number
    • y1: number
    • other: null | RuntimeObject
    • x2: number
    • y2: number
    • enableLimit: boolean
    • referenceAngle: number
    • lowerAngle: number
    • upperAngle: number
    • enableMotor: boolean
    • motorSpeed: number
    • maxMotorTorque: number
    • collideConnected: boolean
    • variable: Variable

    Returns void

  • Parameters

    • x1: number
    • y1: number
    • other: null | RuntimeObject
    • x2: number
    • y2: number
    • axisAngle: number
    • frequency: number
    • dampingRatio: number
    • enableMotor: boolean
    • motorSpeed: number
    • maxMotorTorque: number
    • collideConnected: boolean
    • variable: Variable

    Returns 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

  • 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