rfw2d
    Preparing search index...

    Class SpriteBatcher<O>

    Type Parameters

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    batches: B<O>[] = []

    Batches. All batches in this collection are at least partially occupied.

    batchPool: Pool<SpriteBatch<O, E<O>>> = ...
    changeTracker: ChangeTracker

    Changes to objects will be propagated to the change tracker

    entryPool: Pool<SpriteBatchEntry<O>> = ...
    maximums?: { maxSpriteCount: number; maxTextureCount: number }
    queuedEntries: E<O>[] = []

    New entries are queued until all changes are applied to a batch.

    Accessors

    • get size(): number

      Entries across all batches. Does not respect queued adds/deletes.

      Returns number

    Methods

    • Check if entry can be added to batch.

      Parameters

      • entry: E

        Entry

      • batch: B

        Batch

      • OptionaladditionalSize: number

        Optional, if set this is the additional size required

      Returns boolean

      true if entry fits into batch

    • Mark an entry as changed. Changes are queued, apply with Batcher#finalize.

      Parameters

      • entry: E

        Changed entry

      Returns boolean

      true if the entry was present

      Change handling code for the given entry will only be called once, even if this method is called multiple times with the same entry.

    • Move data within a batch. Used if e.g. entries change size and multiple entries must be moved to fill gaps or crate space.

      Parameters

      • batch: B<O>

        Affected batch

      • target: number

        Target element offset

      • start: number

        Start element offset

      • end: number

        End element offset

      Returns void

      Generally should call copyWithin on batch storage or its buffer.

    • Delete an entry. Deletes are queued unless the entry is itself queued for add, apply with Batcher#finalize.

      Parameters

      • entry: E

        Entry

      Returns boolean

      true if an entry was deleted/queued

      Deletion be done once, even if this method is called multiple times with the same entry.

    • Find an entry for object by doing a linear search through all batches and entries.

      Parameters

      • object: O

        Object to find entry for

      Returns undefined | E<O>

      First entry, if present

      If Batcher#add was called multiple times with the same object, multiple entries can exist for the same object. In this case this method returns only the first entry it finds.

      Generally, the returned entry from Batcher#add should be stored to then reuse it for Batcher#change and Batcher#change calls.