Table of Contents

Class SkiaSpriteSet

Namespace
DrawnUi.Controls
Assembly
DrawnUi.Maui.dll

Stateful sprite switcher that PRE-CREATES one SkiaSprite per integer state via Define(). Base OnChangeState swaps the active child to the precreated sprite atomically. Subclasses can override OnChangeState, call base, then adjust CurrentSprite (e.g., ScaleX).

public class SkiaSpriteSet : ContentLayout, INotifyPropertyChanged, IEffectControlProvider, IToolTipElement, IContextFlyoutElement, IAnimatable, IVisualElementController, IElementController, IView, ITransform, IElement, IVisualTreeElement, IContainer, IList<IView>, ICollection<IView>, IEnumerable<IView>, IEnumerable, IHasAfterEffects, ISkiaDisposable, ISkiaGridLayout, ISkiaLayout, ISkiaControl, IDrawnBase, ICanBeUpdatedWithContext, ICanBeUpdated, ILayoutInsideViewport, IInsideViewport, IDisposable, IVisibilityAware, ISkiaGestureListener, IWithContent
Inheritance
SkiaSpriteSet
Implements
Inherited Members
Extension Methods

Constructors

SkiaSpriteSet()

public SkiaSpriteSet()

Fields

StateProperty

public static readonly BindableProperty StateProperty

Field Value

BindableProperty

Properties

CurrentSprite

The currently active SkiaSprite instance.

public SkiaSprite CurrentSprite { get; }

Property Value

SkiaSprite

HitBoxAuto

This can be absolutely false if we are inside a cached rendering object parent that already moved somewhere. So coords will be of the moment we were first drawn, while if cached parent moved, our coords might differ. todo detect if parent is cached somewhere and offset hotbox by cached parent movement offset... todo think about it baby =) meanwhile just do not set gestures below cached level

public override SKRect HitBoxAuto { get; }

Property Value

SKRect

State

Current integer state. Setting this triggers OnChangeState.

public int State { get; set; }

Property Value

int

Methods

Define(int, string, int, int, double, int, bool, SpritePlacementConfig)

Create and register a sprite for a state, preconfiguring Source, Columns, Rows, FPS and Repeat. If this state equals the current State and no active sprite exists yet, it becomes active immediately.

public SkiaSpriteSet Define(int state, string source, int columns, int rows, double fps = 15, int repeat = -1, bool autoPlay = true, SpritePlacementConfig placement = null)

Parameters

state int
source string
columns int
rows int
fps double
repeat int
autoPlay bool
placement SpritePlacementConfig

Returns

SkiaSpriteSet

InvalidateInternal()

Soft invalidation, without requiring update. So next time we try to draw this one it will recalc everything.

public override void InvalidateInternal()

MeasureSelf(SKRect, float, float, float)

Self measuring, for top controls and those invalidated-redrawn when parents didn't re-measure them

protected override void MeasureSelf(SKRect destination, float widthRequest, float heightRequest, float scale)

Parameters

destination SKRect
widthRequest float
heightRequest float
scale float

OnChangeState(int, int)

Base: swap active child to the precreated sprite for newState. Subclasses should call base first, then adjust CurrentSprite (e.g., ScaleX).

protected virtual void OnChangeState(int oldState, int newState)

Parameters

oldState int
newState int