Skip to content

audio-source-2d.entity overview


Table of contents


utils

AudioSource2dEntity (class)

2D counterpart of AudioSource3dEntity - see that class's doc for the three placement modes (static/attached/transient). rotation is a plain angle (radians), same convention as Entity2d.

Signature

export declare class AudioSource2dEntity<TypeDoc> {
  constructor(public readonly source: TypeDoc['aTypeDoc']['source'], private readonly attachTo?: IPositionable2d | null)
}

playOneShot (static method)

Spawn a transient, self-disposing one-shot sound at a fixed position - see AudioSource3dEntity.playOneShot's doc for the full contract.

Signature

public static playOneShot<TypeDoc extends Gg2dWorldTypeDocRepo = Gg2dWorldTypeDocRepo>(
    world: Gg2dWorld<TypeDoc>,
    descriptor: AudioSourceDescriptor<TypeDoc['aTypeDoc']['clip']>,
    position: Point2,
    rotation: number = 0,
  ): AudioSource2dEntity<TypeDoc>

play (method)

Signature

public play(): void

pause (method)

Signature

public pause(): void

stop (method)

Signature

public stop(): void

tickOrder (property)

Signature

readonly tickOrder: number