Options
All
  • Public
  • Public/Protected
  • All
Menu
classdesc

Creates a DuckEngine Area

description

The Area Class. Detects Hitboxes entering and leaving an area

since

2.0.0

Hierarchy

Index

Constructors

constructor

Properties

attachOffset

attachOffset: Vector2
memberof

PhysicsBody

description

The offset between the PhysicsBody that self is attached to

since

2.0.0

attachedChildren

attachedChildren: PhysicsBody<Duck.Types.Texture.Type>[]
memberof

PhysicsBody

description

PhysicsBodies that are attached

since

2.0.0

bodies

memberof

Area

description

An array of PhysicsBodies that are currently in the area

since

2.0.0

bounds

bounds: BoundsLike
memberof

PhysicsBody

description

The bounds of the PhysicsBody

since

2.0.0

collider

collider: undefined | Collider
memberof

PhysicsBody

description

The Collider instance of the PhysicsBody

since

2.0.0

collidesWith

memberof

PhysicsBody

description

An array or group of GameObjects that can collide with the PhysicsBody

since

2.0.0

collisionFilter

collisionFilter: PhysicsBody<Duck.Types.Texture.Type>[]
memberof

Area

description

An array of PhysicsBodies with Hitboxes to check for entering and leaving the area

since

2.0.0

enabled

enabled: boolean
memberof

PhysicsBody

description

Determines if the PhysicsBody._update is called by the Scene.physicsServer used by Scene.physicsList , changing this value does nothing, must use PhysicsBody.setEnabled

since

2.0.0

game

game: Game
memberof

PhysicsBody

description

The Game instance

since

2.0.0

h

h: number
memberof

PhysicsBody

description

The height of the GameObject

since

2.0.0

hitbox

hitbox: undefined | Hitbox
memberof

PhysicsBody

description

The Collider Hitbox of the PhysicsBody

since

2.0.0

Readonly id

id: string
memberof

PhysicsBody

description

The unique identifier for a GameObject

since

2.0.0

isAttached

isAttached: boolean
memberof

PhysicsBody

description

Determines if the PhysicsBody is attached to another PhysicsBody

since

2.0.0

onBodyEnter

onBodyEnter: undefined | ((physicsBody: PhysicsBody<Duck.Types.Texture.Type>) => unknown)
memberof

Area

description

Callback to call when a PhysicsBody with a Hitbox enters

since

2.0.0

onBodyLeave

onBodyLeave: undefined | ((physicsBody: PhysicsBody<Duck.Types.Texture.Type>) => unknown)
memberof

Area

description

Callback to call when a PhysicsBody with a Hitbox leaves the area

since

2.0.0

options

memberof

PhysicsBody

description

PhysicsBody config, includes: type - KinematicBody | RigidBody | StaticBody

defaults: { type: 'KinematicBody'}

since

2.0.0

physics

physics: { addCollider: any; addHitbox: any; setBounds: any }
memberof

PhysicsBody

description

Object that has all the physics method

since

2.0.0

Type declaration

position

position: Vector2
memberof

PhysicsBody

description

The current global position of the GameObject

since

2.0.0

r

r: number
memberof

PhysicsBody

description

The radius of the GameObject

since

2.0.0

scene

scene: Scene
memberof

PhysicsBody

description

The Scene instance

since

2.0.0

Readonly shape

memberof

PhysicsBody

description

The shape of the GameObject, 'rect', 'circle', 'roundrect', or 'sprite'

since

2.0.0

velocity

velocity: Vector2
memberof

PhysicsBody

description

The velocity of the PhysicsBody

since

2.0.0

w

w: number
memberof

PhysicsBody

description

The width of the GameObject

since

2.0.0

Methods

_update

  • _update(): void
  • memberof

    Area

    description

    Updates the Area, check for Hitbox intersections with the passed collisionFilter array of PhysicsBodies

    DO NOT CALL MANUALLY! CALLED IN SCENE.PHYSICS SERVER.__tick

    since

    2.0.0

    Returns void

accelerateVelocity

  • accelerateVelocity(target: Vector2, amount: number): void

Protected addBody

applyFriction

  • applyFriction(frictionAmount: Vector2): void
  • memberof

    PhysicsBody

    description

    Applies friction to the velocity by an amount, PhysicsBody.options.type must be KinematicBody or RigidBody

    since

    2.0.0

    Parameters

    • frictionAmount: Vector2

      The value to decrease the velocity by

    Returns void

applyGravity

  • applyGravity(gravity: Vector2): void
  • memberof

    PhysicsBody

    description

    Applies gravity to the velocity by a Vector2, PhysicsBody.options.type must be KinematicBody or RigidBody

    since

    2.0.0

    Parameters

    • gravity: Vector2

      The Vector2 to add to the velocity by

    Returns void

attachChild

attachTo

autoFitHitbox

  • autoFitHitbox(offset?: Vector2): void

bodyIsInArea

bounceVelocityBounds

  • bounceVelocityBounds(bounds?: BoundsLike, restitution?: number): void

detachChild

detachFrom

getBottom

  • getBottom(): number

getCenter

getCenterX

  • getCenterX(): number

getCenterY

  • getCenterY(): number

getLeft

  • getLeft(): number

getRight

  • getRight(): number

getTop

  • getTop(): number

isColliding

isCollidingGroup

reflectVelocity

  • reflectVelocity(): void
  • memberof

    PhysicsBody

    description

    Reflects the velocity, sets the velocity as the opposite value of the velocity, PhysicsBody.options.type must be KinematicBody or RigidBody

    example

    myPhysicsBody.setVelocity('x', 3); myPhysicsBody.reflect(); // velocity: 0, -3

    since

    2.0.0

    Returns void

Protected removeBody

scaleHitbox

setEnabled

  • setEnabled(enabled: boolean): boolean

setType

setVelocity

  • setVelocity(axis: "x" | "y", pxPerSecond: number): void
  • memberof

    PhysicsBody

    description

    Sets the velocity based on an axis, PhysicsBody.options.type must be KinematicBody

    since

    2.0.0

    Parameters

    • axis: "x" | "y"

      The axis to set the velocity of

    • pxPerSecond: number

      The value to set the velocity axis as, in pixels per second

    Returns void

setVelocityX

  • setVelocityX(pxPerSecond: number): void
  • memberof

    PhysicsBody

    description

    Sets the velocity.x, PhysicsBody.options.type must be KinematicBody

    since

    2.0.0

    Parameters

    • pxPerSecond: number

      The value to set the velocity axis as, in pixels per second

    Returns void

setVelocityY

  • setVelocityY(pxPerSecond: number): void
  • memberof

    PhysicsBody

    description

    Sets the velocity.y, PhysicsBody.options.type must be KinematicBody

    since

    2.0.0

    Parameters

    • pxPerSecond: number

      The value to set the velocity.y as, in pixels per second

    Returns void

Generated using TypeDoc