Balkan-Ram-Games/spriteloop-defold/spriteloop
SpriteLoop component playback API.
- GitHub: Balkan-Ram-Games/spriteloop-defold — pinned to
v0.15.0(released while Defold 1.14.0 was current)- This repo publishes no stable release. Pick a tag from Balkan-Ram-Games/spriteloop-defold tags and add its Source code (zip) URL — for the pinned tag,
https://github.com/Balkan-Ram-Games/spriteloop-defold/archive/refs/tags/v0.15.0-alpha.zip— togame.projectunder[project]dependencies, then Fetch Libraries in the Defold editor. - Run
bunx @defold-typescript/cli resolveto materialize its types. - Import it under a namespace alias of your choice:
import * as spriteloop from "spriteloop"
- This repo publishes no stable release. Pick a tag from Balkan-Ram-Games/spriteloop-defold tags and add its Source code (zip) URL — for the pinned tag,
- Asset Portal: spriteloop-defold
Functions
spriteloop.play_anim(url: string | hash | url, animation_id: string, options: table): booleanspriteloop.stop_anim(url: string | hash | url)spriteloop.set_time(url: string | hash | url, seconds: number, options: table)spriteloop.set_frame(url: string | hash | url, frame_index: number, options: table)spriteloop.consume_events(url: string | hash | url): tablespriteloop.listen(url: string | hash | url, event_name: string, callback: function): numberspriteloop.unlisten(url: string | hash | url, listener_or_event_name: number | string): booleanspriteloop.dispatch_events(url: string | hash | url): tablespriteloop.set_playback_rate(url: string | hash | url, rate: number)spriteloop.set_visible(url: string | hash | url, visible: boolean)spriteloop.set_tint(url: string | hash | url, r: number, g: number, b: number)spriteloop.clear_tint(url: string | hash | url)spriteloop.set_skin(url: string | hash | url, skin_id: string): booleanspriteloop.set_variant(url: string | hash | url, part_id: string, variant_id: string): booleanspriteloop.clear_variant(url: string | hash | url, part_id: string): booleanspriteloop.clear_variants(url: string | hash | url)spriteloop.get_part_transform(url: string | hash | url, part_id: string, options?: table): tablespriteloop.debug_destroy_component(url: string | hash | url): booleanspriteloop.get_info(url: string | hash | url): tablespriteloop.get_cache_info(): table
spriteloop.play_anim(url: string | hash | url, animation_id: string, options: table): boolean
Plays an animation on a SpriteLoop component.
Parameters
url:string | hash | url— SpriteLoop component URL.animation_id:string— Animation id or name to play. Exact ids are matched before names.options:table— Optional table with loop and emit_events booleans. emit_events controls the full playback session and defaults to true.
Returns
played:boolean— True when the animation id or name exists and playback started.
spriteloop.stop_anim(url: string | hash | url)
Stops playback on a SpriteLoop component.
Parameters
url:string | hash | url— SpriteLoop component URL.
spriteloop.set_time(url: string | hash | url, seconds: number, options: table)
Sets playback time in seconds.
Parameters
url:string | hash | url— SpriteLoop component URL.seconds:number— Playback time.options:table— Optional table with emit_events. Destination-frame events emit by default.
spriteloop.set_frame(url: string | hash | url, frame_index: number, options: table)
Sets the current frame index.
Parameters
url:string | hash | url— SpriteLoop component URL.frame_index:number— Frame index. 0️⃣ 0-based; passed tospriteloopunchanged.options:table— Optional table with emit_events. Destination-frame events emit by default.
spriteloop.consume_events(url: string | hash | url): table
Returns and clears SpriteLoop animation events collected since the previous call.
Parameters
url:string | hash | url— SpriteLoop component URL.
Returns
events:table— Array of event tables with event_name, name, data, animation_id, animation_name, frame, and source_frame.
spriteloop.listen(url: string | hash | url, event_name: string, callback: function): number
Registers a Lua callback for a SpriteLoop animation event on one component.
Parameters
url:string | hash | url— SpriteLoop component URL.event_name:string— Event name to listen for.callback:function— Function called with the event table when dispatch_events consumes a matching event.
Returns
listener_id:number— Numeric listener id that can be passed to unlisten.
spriteloop.unlisten(url: string | hash | url, listener_or_event_name: number | string): boolean
Removes SpriteLoop event listeners for one component.
Parameters
url:string | hash | url— SpriteLoop component URL.listener_or_event_name:number | string— Optional listener id or event name. Omit to remove all listeners for the component.
Returns
removed:boolean— True when one or more listener entries existed.
spriteloop.dispatch_events(url: string | hash | url): table
Consumes queued events and calls matching Lua listeners registered with listen.
Parameters
url:string | hash | url— SpriteLoop component URL.
Returns
events:table— Array of consumed event tables.
spriteloop.set_playback_rate(url: string | hash | url, rate: number)
Sets playback rate multiplier.
Parameters
url:string | hash | url— SpriteLoop component URL.rate:number— Playback rate multiplier.
spriteloop.set_visible(url: string | hash | url, visible: boolean)
Sets SpriteLoop component visibility.
Parameters
url:string | hash | url— SpriteLoop component URL.visible:boolean— Visibility state.
spriteloop.set_tint(url: string | hash | url, r: number, g: number, b: number)
Sets a whole-character runtime RGB tint multiplier.
Parameters
url:string | hash | url— SpriteLoop component URL.r:number— Red multiplier clamped to 0..1.g:number— Green multiplier clamped to 0..1.b:number— Blue multiplier clamped to 0..1.
spriteloop.clear_tint(url: string | hash | url)
Resets the whole-character runtime RGB tint multiplier to white.
Parameters
url:string | hash | url— SpriteLoop component URL.
spriteloop.set_skin(url: string | hash | url, skin_id: string): boolean
Sets the active runtime skin.
Parameters
url:string | hash | url— SpriteLoop component URL.skin_id:string— Skin id or name. Exact ids are matched before names.
Returns
changed:boolean— True when the skin id or name exists.
spriteloop.set_variant(url: string | hash | url, part_id: string, variant_id: string): boolean
Overrides one part variant. Pass "default" to clear the part's manual variant override.
Parameters
url:string | hash | url— SpriteLoop component URL.part_id:string— Part id, key, or name. Exact ids are matched before keys and names.variant_id:string— Variant id, key, or name for the selected part. Exact ids are matched before keys and names. If a real variant matches "default", it is selected instead of clearing the override.
Returns
changed:boolean— True when the part and variant resolve to a matching pair, or when "default" successfully clears the override.
spriteloop.clear_variant(url: string | hash | url, part_id: string): boolean
Clears one part variant override.
Parameters
url:string | hash | url— SpriteLoop component URL.part_id:string— Part id, key, or name. Exact ids are matched before keys and names.
Returns
changed:boolean— True when the part id or name exists.
spriteloop.clear_variants(url: string | hash | url)
Clears all part variant overrides.
Parameters
url:string | hash | url— SpriteLoop component URL.
spriteloop.get_part_transform(url: string | hash | url, part_id: string, options?: table): table
Returns the current resolved component-local transform of an image or Empty Part.
Parameters
url:string | hash | url— SpriteLoop component URL.part_id:string— Part id, key, or name. Exact ids are matched before keys and names.options?:table— Optional origin setting. Use origin "pivot" (default) or "center" for the transformed base-image center.
Returns
transform:table— Table with position, rotation, scale, skew, and opacity, or nil when the part is unavailable.
spriteloop.debug_destroy_component(url: string | hash | url): boolean
Debug helper that releases one SpriteLoop component runtime instance.
Parameters
url:string | hash | url— SpriteLoop component URL.
Returns
destroyed:boolean— True when a live component instance was destroyed.
spriteloop.get_info(url: string | hash | url): table
Gets debug playback and package information.
Parameters
url:string | hash | url— SpriteLoop component URL.
Returns
info:table— Package and playback information, including pending_event_count, max_pending_events, and dropped_event_count.
spriteloop.get_cache_info(): table
Gets shared package and texture cache diagnostics.
Returns
info:table— Cache entries, reference counts, texture counts, and approximate texture bytes.