Api Sandbox SpriteRenderer
class

SpriteRenderer

public sealed class SpriteRenderer : Renderer

Renders a sprite in the world

Constructors

SpriteRenderer()

Properties

Name Type Description
Sprite Sprite The sprite resource to render. This can be completely static or contain animation(s).
StartingAnimationName String The animation that this sprite should start playing when the scene starts.
PlaybackSpeed Single The playback speed of the animation. 0 is paused, and negative values will play the animation in reverse.
Size Vector2 The width and height of the sprite in world units.
Color Color The color of the sprite. This is multiplied with the texture color.
OverlayColor Color
Additive virtual Boolean Whether or not the sprite should be rendered additively.
Shadows virtual Boolean Whether or not the sprite should cast shadows.
Opaque virtual Boolean Whether or not the sprite should be rendered opaque. If true, any semi-transparent pixels will be dithered.
AlphaCutoff Single Alpha threshold for discarding pixels. Pixels with alpha below this value will be discarded. Only used when Opaque is true. Range: 0.0 (transparent) to 1.0 (opaque). Default is 0.5.
Lighting Boolean Whether or not the sprite should be lit by the scene's lighting system. Otherwise it will be unlit/fullbright.
DepthFeather Single Amount of feathering applied to the depth, softening its intersection with geometry.
FogStrength Single The strength of the fog effect applied to the sprite. This determines how much the sprite blends with any fog in the scene.
FlipHorizontal Boolean Whether or not the sprite should be flipped horizontally.
FlipVertical Boolean Whether or not the sprite should be flipped vertically.
TextureFilter FilterMode The texture filtering mode used when rendering the sprite. For pixelated sprites, use Point.
Billboard BillboardMode Alignment mode for the sprite's billboard behavior.
IsSorted virtual Boolean Whether or not the sprite should be sorted by depth. If the sprite is opaque, this can be turned off for a performance boost if not needed.
OnAnimationStart Action<String> This action is invoked when an animation starts playing. The string parameter is the name of the animation that started.
OnAnimationEnd Action<String> This action is invoked when an animation finishes playing or has looped. The string parameter is the name of the animation.
OnBroadcastMessage Action<String> This action is invoked when advancing to a new frame that has broadcast messages. The string parameter is the message being broadcast.
CurrentAnimation Animation The animation that is currently being played. Returns null if no sprite is set or the sprite has no animations.
CurrentFrameIndex Int32 The index of the current frame being displayed. This will change over time if the sprite is animated, and can be set to go to a specific frame even during playback.
IsAnimated Boolean Whether or not the sprite is animated. This is true if the sprite has more than one animation.
Texture Texture The texture of the current frame being displayed. Returns a transparent texture when no valid frame is available.
ComponentVersion virtual Int32

Methods

Void PlayAnimation(Int32 index)

Play an animation by index (the first animation is index 0).

Void PlayAnimation(String name)

Play an animation by name.

Assembly: Sandbox.Engine Namespace: Sandbox Full Name: Sandbox.SpriteRenderer