Skip to content

Latest commit

 

History

History
65 lines (44 loc) · 1.3 KB

File metadata and controls

65 lines (44 loc) · 1.3 KB

Sprite

Sprite is the normal textured drawable.

Responsibilities

  • render a Texture or RenderTexture
  • apply transform/origin/tint state
  • use textureFrame for sub-rect rendering
  • participate in the normal scene graph through Container

Important properties

  • texture
  • textureFrame
  • width
  • height
  • inherited transform/tint/visibility state

Rendering

Use it through the normal scene flow:

sprite.render(renderBackend)

or place it in a container and render the container.

Notes

  • WebGPU supports the normal built-in sprite path
  • Text, Video, and RenderTexture display all ride on the sprite path
  • batching is internal and not part of the public API contract

Animated Clips

For clip playback, use AnimatedSprite:

import { AnimatedSprite } from 'exojs';

animatedSprite.play('walk');
animatedSprite.pause();
animatedSprite.resume();
animatedSprite.stop();

AnimatedSprite supports:

  • named clips
  • loop / non-loop playback
  • onFrame and onComplete signals
  • AnimatedSprite.fromSpritesheet(...) from spritesheet animation metadata

zIndex Sorting

Use sortable containers for deterministic draw order:

container.sortableChildren = true;
sprite.zIndex = 10;

When sorting is disabled, insertion order remains the default behavior.