Jazz2::Actors::ActorBase::ActorRenderer class

Actor renderer.

Base classes

class nCine::BaseSprite
Base class for textured sprites.

Constructors, destructors, conversion operators

ActorRenderer(ActorBase* owner)
Creates a new instance.

Public functions

void Initialize(ActorRendererType type)
Initializes the renderer to the specified renderer type.
void SetPalette(std::int32_t paletteOffset)
Selects a recolor palette override.
void SetIndexed(bool indexed, std::int32_t basePaletteOffset)
Marks whether the current graphic is indexed and which palette region it samples.
void OnUpdate(float timeMult) override
Called every frame to update the node state.
auto OnDraw(RenderQueue& renderQueue) -> bool override
Called when the node needs to be drawn, returning true if a command was added.
auto IsAnimationRunning() -> bool
Returns true if animation is running.
auto GetRendererType() const -> ActorRendererType
Returns active renderer type.
void UpdateAnchor()
Points the sprite's anchor at the hotspot of the frame being shown.

Public variables

bool AnimPaused
Whether the animation is paused.
Vector2i FrameConfiguration
Frame configuration.
Vector2i FrameDimensions
Frame dimensions.
const Resources::GenericGraphicResource* FrameSource
Sheet the frames come from, or nullptr when the frames form a regular grid.
AnimationLoopMode LoopMode
Animation loop mode.
std::int32_t FirstFrame
Frame offset.
std::int32_t FrameCount
Frame count.
float AnimDuration
Animation duration (in normalized frames).
float AnimTime
Current animation progress.
std::int32_t CurrentFrame
Current animation frame.
Vector2f Hotspot
Hotspot of the current animation, as authored (never mirrored - see UpdateAnchor()).

Protected functions

void textureHasChanged(Texture* newTexture) override
Performs the required tasks upon a change to the texture.

Function documentation

Jazz2::Actors::ActorBase::ActorRenderer::ActorRenderer(ActorBase* owner)

Creates a new instance.

Parameters
owner Actor that owns this renderer

void Jazz2::Actors::ActorBase::ActorRenderer::SetPalette(std::int32_t paletteOffset)

Selects a recolor palette override.

The override is a flat offset into the shared palette texture (e.g., paletteRow * @ref ContentResolver::ColorsPerPalette), or -1 for no override. It takes precedence over the base palette used for plain (non-recolored) indexed sprites; see SetIndexed.

void Jazz2::Actors::ActorBase::ActorRenderer::SetIndexed(bool indexed, std::int32_t basePaletteOffset)

Marks whether the current graphic is indexed and which palette region it samples.

basePaletteOffset is the animation's palette offset (0 = default sprite palette, the gem-gradient rows for gems). Indexed sprites render through the palette shader unless a recolor override is set via SetPalette. Set automatically from the current animation by ActorBase::RefreshAnimation.

void Jazz2::Actors::ActorBase::ActorRenderer::UpdateAnchor()

Points the sprite's anchor at the hotspot of the frame being shown.

Flipping mirrors the texture inside the sprite's quad, so the hotspot has to be mirrored with it. The quad covers the frame's own area, which for a tightly packed sheet is smaller than the animation's cell, so the mirroring has to happen within that area - doing it within the cell (as a regular grid can) would displace every flipped frame by the trimmed margin.