API/core/SpriteRenderer/

SpriteRenderer

Renders a Sprite for 2D graphics.

Hierarchy: Renderer

constructor 

new SpriteRenderer(entity: Entity)

Create a sprite renderer instance.

Parameters

  • entity

    Entity to which the sprite renderer belongs

instanceId ReadOnly

instanceId: number = ++EngineObject._instanceIdCounter

Engine unique id.

isCulled 

isCulled: boolean = false

Whether it is clipped by the frustum, needs to be turned on camera.enableFrustumCulling.

shaderData ReadOnly

shaderData: ShaderData = ...

ShaderData related to renderer.

bounds 

get bounds(): BoundingBox

The bounding volume of the renderer.

color 

get color(): Color

Rendering color for the Sprite graphic.

set color(Color): void

destroyed 

get destroyed(): boolean

Indicates whether the component is destroyed.

enabled 

get enabled(): boolean

Indicates whether the component is enabled.

set enabled(boolean): void

engine 

get engine(): Engine

The engine which the component's entity belongs to.

entity 

get entity(): Entity

The entitiy which the component belongs to.

flipX 

get flipX(): boolean

Flips the sprite on the X axis.

set flipX(boolean): void

flipY 

get flipY(): boolean

Flips the sprite on the Y axis.

set flipY(boolean): void

materialCount 

get materialCount(): number

Material count.

set materialCount(number): void

scene 

get scene(): Scene

The scene which the component's entity belongs to.

sprite 

get sprite(): Sprite

The Sprite to render.

set sprite(Sprite): void

destroy 

destroy(): void

Destory this instance.

getInstanceMaterial 

getInstanceMaterial(): Material

Get the first instance material.

Returns

The first instance material
getInstanceMaterial(index: number): Material

Get the first instance material by index.

remarksCalling this function for the first time after the material is set will create an instance material to ensure that it is unique to the renderer.

Parameters

  • index

    Material index

Returns

Instance material

getInstanceMaterials 

getInstanceMaterials():

Get all instance materials.

remarksCalling this function for the first time after the material is set will create an instance material to ensure that it is unique to the renderer.

Returns

All instance materials

getMaterial 

getMaterial(): Material

Get the first material.

Returns

The first material
getMaterial(index: number): Material

Get the first material by index.

Parameters

  • index

    Material index

Returns

Material

getMaterials 

getMaterials():

Get all materials.

Returns

All materials

setMaterial 

setMaterial(material: Material): void

Set the first material.

Parameters

  • material

    The first material

setMaterial(index: number, material: Material): void

Set material by index.

Parameters

  • index

    Material index

  • material

    The material

setMaterials 

setMaterials(materials: Material[]): void

Set all materials.

Parameters

  • materials

    All materials

update 

update(deltaTime: number): void

Parameters

  • deltaTime