• Runtimes
  • How to scale skeleton at a pivot point

Related Discussions
...

Hi. I use spine libgdx runtime. I can scale x,y by get the root bone of the skeleton and scale it. But how do i set a pivot point to scale the skeleton ? thanks.

You can manipulate the projection matrix of the Batch you use to render the skeleton. Otherwise you can have the root bone, then second bone that all your other bones are attached to. Programmatically position the root (to set the scale origin) and the second bone (to set the skeleton location), then scale the root.

It looks like a little complicate 🙂 , can you post some sample code ? Very appreciate!

float originX = 100, originY = 100;

Matrix4 proj = batch.getProjectionMatrix();
proj.translate(originX, originY, 0);
proj.scale(1.2f, 1.2f, 1);
proj.translate(-originX, -originY, 0);

batch.begin();
renderer.draw(batch, skeleton); // Draw the skeleton images.
batch.end();

debugRenderer.getShapeRenderer().setProjectionMatrix(proj);
debugRenderer.draw(skeleton); // Draw debug lines.

proj.translate(originX, originY, 0);
proj.scale(1 / 1.2f, 1 / 1.2f, 1);
proj.translate(-originX, -originY, 0);

Drawing debug is optional of course.

good , thank you very much.