local spriteloop = require "spriteloop.spriteloop"
function init(self)
self.step_listener = spriteloop.listen("#robot", "step", function(event)
print("step at frame", event.frame)
end)
end
function update(self, dt)
spriteloop.dispatch_events("#robot")
end
function final(self)
spriteloop.unlisten("#robot", self.step_listener)
end
I couldn’t get the callback example from the documentation to work.
Using the documented approach:
local spriteloop = require "spriteloop.spriteloop"
function init(self)
self.step_listener = spriteloop.listen("#robot", "step", function(event)
print("step at frame", event.frame)
end)
end
function update(self, dt)
spriteloop.dispatch_events("#robot")
end
function final(self)
spriteloop.unlisten("#robot", self.step_listener)
end
No callbacks are triggered.
However, this approach works:
function update(self, dt)
local events = spriteloop.dispatch_events("#robot")
for _, event in ipairs(events) do
print(event.name, event.frame)
end
end
So the events are definitely being generated and returned by dispatch_events(), but the listener callback never seems to be called.
Off the top of my head, possible reasons it may not work:
There might still be a bug with the component not updating and reading an old file without events.
The extension version may not be updated.
The events may have different names.
The #component name may be incorrect.
The animation has to be played after the listeners are defined.
You should use either the consume_events approach or the listeners approach, not both.
Events are stored as a list/queue. The listeners approach consumes them for you and triggers the callback. The consume approach gives you more control, but if the events are not consumed, they will pile up.
P.S.
It’s too early and I can’t read!
If the other approach works, then it’s probably not an issue with the component not updating or the extension version.
Please check the test scene and let me know if it works or not. Feel free to open an issue on GitHub if it still fails.
I think there is a general issue with the native extension server. I’m getting a different error while testing another extension(s). Maybe @ekharkunov might help
ext.manifest
com.defold.extender.ExtenderException: java.io.IOException: Cannot run program "clang++" (in directory "/var/folders/tn/5rwq3j0d41z37qlbh_15j9m80000gn/T/job5852987532467959181"): Failed to exec spawn helper: pid: 22121, exit code: 1, error: 0 (none)
Possible reasons:
- Spawn helper ran into JDK version mismatch
- Spawn helper ran into unexpected internal error
- Spawn helper was terminated by another process
Possible solutions:
- Restart JVM, especially after in-place JDK updates
- Check system logs for JDK-related errors
- Re-install JDK to fix permission/versioning problems
- Switch to legacy launch mechanism with -Djdk.lang.Process.launchMechanism=FORK
local spriteloop = require “spriteloop.spriteloop”
function init(self)
local component = “#spriteloop”
spriteloop.set_skin(component, “test”)
spriteloop.set_variant(component, “Artboard 13”, “Artboard 5”)
end
Can be something with the names. In all my examples I use dashes and underscore instead of spaces. I can check the code later today. It can be something like the animation IDs issue.
P.S. I haven’t had the chance to test te beta yet.
Pushed a small fix for the Defold extension and updated the app as well.
Changes in this update:
Fixes skin renaming issues
Adds part and variant keys to the API
I also created a separate GitHub repo for SpriteLoop app issue tracking, so app-related bugs and feature requests can go there.
There is also a Discussions board in the repo if anyone wants deeper discussions about workflows, feature ideas, or other SpriteLoop-related topics.
This forum thread is still the main place for updates, but it has grown quite a bit, so I thought having a dedicated repo and discussions board might help keep things organized, and maybe save the forum moderators from too many SpriteLoop notifications
Love it—the new interface looks really cool. I hope future versions include features for color manipulation; you know, for images that need to change color at runtime—it’s pretty tough dealing with a bunch of all-white sprites, as you can imagine!