Related Discussions
...

Hi,
I'm using sfml, spine c runtimes, C++, xcode.
I need to scale my character down dynamically at runtime.
Is there a simple way to scale the whole image.

Cheers.


ok, figured it out.
find the root bone, then scaleX and scaleY to the desired scale factor.
Most important was to not forget to skeleton_updateWorldTransform.

Worked for me on some example-projects, but not for the "raptor" example.
Playing the "Jump" animation with the "root" bone scaled down has no effect on the skeleton and attachments size at all.
Other animations like "walk" do work fine. Please see the screenshot.

Am I doing it wrong or was something "keyed" that gets priority at runtime?

local root_bone = self.skeleton:findBone(root_bone_name or "root")
root_bone.scaleX = new_scale_x
root_bone.scaleY = new_scale_y or new_scale_x

(played animation queue: walk, walk, jump, walk)

Could you show me how you setup the queue? I've tried this locally and didn't see the issue.

I took the unmodified example files from the export folder (raptor.json, raptor.atlas, raptor.png).

This is my setup.

local raptor = spine.Actor(lfs.DROPBOX.."/spine-data", "raptor.json", "raptor.atlas")
raptor:setPosition(-200, 0) 

---

 sets skeleton.x and skeleton.y
raptor:setScale(.25) 

---

 scales the root bone as shown in post above
raptor:setAnimation("walk") 

---

 play a sequence of chained animations
raptor:queueAnimation("walk") 

---

 build animation queue
raptor:queueAnimation("walk")
raptor:queueAnimation("Jump")
raptor:queueAnimation("walk", true)

This is what the *:setAnimation() and *:queueAnimation() methods do.
Basically I wrapped some spine methods for convenience. All animations play only on one track entry.

function spine.Actor:setAnimation(new_animation_name, loop, crossfade_time)
    local track_entry = self.animation:setAnimationByName(0, new_animation_name, loop)
    track_entry.mixDuration = crossfade_time or .25
end

function spine.Actor:queueAnimation(animation_name, loop, delay)
    self.animation:addAnimationByName(0, animation_name, loop, delay or 0)
end

self.animation is an AnimationState.new() instance.

I knew something takes priority and overrides it. Now I know what - thank you for giving some insight. A solution would be to nest the "root bone" into another root bone. And never key the top most bone... I guess it should work.

I ended up modifying the viewMatrix. In Codea, this works same as love.graphics.scale() which scales all fallowing drawings. This is quick and works flawless in any case.

I knew I could set the scale factor when loading the data, but I needed also a way to do this dynamically when needed (e.g. Point-And-Click game when character walks away and gets smaller).

Thank you for the quick responses.
You all do great work.

Cheers! :happy: :beer: