Table of Contents

Class SpriteInstancer

Namespace
LibGFX.Core.GameElements
Assembly
LibGFX.dll

Represents a sprite instancer that can render multiple instances of a sprite using instancing.

public class SpriteInstancer : GameElement, IIdentifier, IPropertyTable, ISerialization
Inheritance
SpriteInstancer
Implements
Inherited Members

Constructors

SpriteInstancer(IMaterial)

Initializes a new instance of the SpriteInstancer class with the specified material.

public SpriteInstancer(IMaterial material)

Parameters

material IMaterial

SpriteInstancer(IMaterial, uint)

Initializes a new instance of the SpriteInstancer class with the specified material and number of instances.

public SpriteInstancer(IMaterial material, uint instances)

Parameters

material IMaterial
instances uint

Properties

HasTransparency

Gets a value indicating whether the image contains any transparent pixels.

public override bool HasTransparency { get; }

Property Value

bool

InstanceContainer

The instance container that holds the instances of the sprite.

public RenderInstanceContainer InstanceContainer { get; set; }

Property Value

RenderInstanceContainer

Material

The material used for rendering the sprite instances.

public IMaterial Material { get; set; }

Property Value

IMaterial

Mesh

The mesh used for rendering the sprite instances.

public Mesh Mesh { get; }

Property Value

Mesh

Shader

The shader program used for rendering the sprite instances.

public RenderShader Shader { get; set; }

Property Value

RenderShader

Methods

AddInstance(Transform, Vector4, bool)

Adds a new instance to the sprite instancer with the specified transform and UV transform.

public int AddInstance(Transform transform, Vector4 uvTransform, bool visible = true)

Parameters

transform Transform
uvTransform Vector4
visible bool

Returns

int

BakeInstances(uint)

Bakes the specified number of instances into the sprite instancer.

public void BakeInstances(uint instanceCount = 10)

Parameters

instanceCount uint

Exceptions

ArgumentOutOfRangeException

ComputeAABB()

Computes the axis-aligned bounding box (AABB) of the game element.

public override void ComputeAABB()

CreateInstanceHandle(int)

Creates a new instance handle for the specified instance ID.

public InstanceHandle CreateInstanceHandle(int instanceId)

Parameters

instanceId int

Returns

InstanceHandle

Exceptions

ArgumentOutOfRangeException

Dispose(BaseScene, IRenderDevice)

Disposes the sprite instancer and its resources.

public override void Dispose(BaseScene scene, IRenderDevice renderer)

Parameters

scene BaseScene
renderer IRenderDevice

Init(BaseScene, Viewport, IRenderDevice)

Initializes the sprite instancer with the specified scene, viewport, and renderer.

public override void Init(BaseScene scene, Viewport viewport, IRenderDevice renderer)

Parameters

scene BaseScene
viewport Viewport
renderer IRenderDevice

Render(BaseScene, Viewport, IRenderDevice, Camera)

Renders the sprite instancer using the specified scene, viewport, renderer, and camera.

public override void Render(BaseScene scene, Viewport viewport, IRenderDevice renderer, Camera camera)

Parameters

scene BaseScene
viewport Viewport
renderer IRenderDevice
camera Camera