Class Particle

Represents a particle in the Platfuse game engine.

Hierarchy (view full)

Constructors

Properties

active: boolean = true

Whether the object is active and should be updated

angle: number = 0

Rotation angle (in radians)

angleDamping: number = 1

Rotation slowdown (0-1)

angleVelocity: number = 0

The object's angular velocity

animation?: Animation

The animation of the object sprite.

bounded: boolean = false

Whether the object is bounded by the scene and cannot move outside.

collideObjects: boolean = true

Whether the object collides with other objects

collideTiles: boolean = true

Whether the object is static and should not move

color?: Color

The color of the object (if no sprite).

colorEnd: Color = ...

The color delta of the particle.

colorStart: Color = ...

The starting color of the particle.

damping: number = 1

The object's damping (0-1)

dead: boolean = false

Whether the object is dead and should be removed

elasticity: number = 0

The object's elasticity (0-1)

fadeRate: number = 0.1

The rate at which the particle fades.

family?: string

The family of the object.

flipH: boolean = false

Whether the object is flipped horizontally (mirrored)

flipV: boolean = false

Whether the object is flipped vertically

force: Vector = ...

The force applied to the object (acceleration)

friction: number = 0.8

The object's friction (0-1)

gid?: number

The global ID of the object image from TMX map (if any).

gravityScale: number = 1

How much gravity affects the object

id: number = ...

The ID of the object.

image?: string

The image of the object (if any).

lastPos: Vector = ...

Last position of the object

layerId?: number

The layer ID of the object (if any).

mass: number = 1

The object's mass (0 is static)

maxSpeed: number = 1

Maximum speed

name?: string

The name of the object.

obj?: Record<string, any>
onGround: boolean | Entity = false

The object the entity is standing on

pos: Vector = ...

Current position of the object

properties: Record<string, any> = {}

Custom properties of the object

renderOrder: number = 0

Render order

scene: Scene

The scene the particle belongs to.

shape: Shape = Shape.Rectangle

The shape of the particle.

size: Vector = ...

The size of the object (scaled by tileSize)

sizeDelta: number = 0

The size delta of the particle.

sizeStart: number = 0.1

The starting size of the particle.

solid: boolean = true

Whether the object is solid and collides with other objects

spawnTime: number = 0

Time the entity was spawned

sprite: Sprite = ...

The sprite of the object.

Sprite

stretchScale: number = 0

The scale of the particle's stretch effect.

ttl: number = 0

The time to live (in seconds) of the particle.

type: string = 'Platfuse.Particle'

The type of the particle.

visible: boolean = true

Whether the object is visible and should be drawn

Methods

  • Checks if the entity collides with a tile.

    Parameters

    • tileId: number

      The ID of the tile to check collision with.

    • pos: Vector

      The position of the entity.

    Returns boolean

    True if the entity collides with the tile, false otherwise.

  • Checks if the entity collides with a tile using raycasting.

    Parameters

    • tileId: number

      The data of the tile to check collision with.

    • pos: Vector

      The position of the entity.

    Returns boolean

    True if the entity collides with the tile, false otherwise.

  • Gets the current animation frame of the entity. If the sprite is defined, it returns the animation frame of the sprite. Otherwise, it returns 0.

    Returns number

    The current animation frame.

  • Returns the relative bounding rectangle of the entity. The relative bounding rectangle is calculated by translating the entity's bounding rectangle and moving it based on the position of the scene's camera.

    Returns Box

    The relative bounding rectangle of the entity.

  • Checks if the entity is overlapping with a given position and size.

    Parameters

    • pos: Vector

      The position vector of the other object.

    • size: Vector = ...

      The size vector of the other object.

    Returns boolean

    True if the entity is overlapping with the other object, false otherwise.

  • Sets the animation for the entity.

    Parameters

    • animation: Animation

      The animation to set.

    • flipH: boolean = false

      (Optional) Whether to flip the animation horizontally. Default is false.

    • flipV: boolean = false

      (Optional) Whether to flip the animation vertically. Default is false.

    Returns void