question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

The reason of setOrigin doesn't affect Actor's position

See original GitHub issue

Issue details

Origin is the center of the object. If origin is outside and object having position (0, 0) it’s logical that origin point must be at (0, 0) and object must keep offset from origin and not only affect rotation/scale but position too.

Reproduction steps/code

Actor actor = new Image("something.png");
actor.setPosition(0, 0);
actor.setOrigin(1000, 1000); // Nothing happened
actor.setOrigin(-1000, -1000); // Nothing happened

Version of LibGDX and/or relevant dependencies

1.9.8

Please select the affected platforms

  • Android
  • iOS (robovm)
  • iOS (MOE)
  • HTML/GWT
  • Windows
  • Linux
  • MacOS

Another design issue

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
Darkyenuscommented, Oct 17, 2018

scene2d implements a 2D scenegraph and such has different needs than 3D scenegraph that you are probably familiar with. In this context, it makes more sense that Actors origin comes into consideration only for scaling and rotation, as it simplifies most operations that deal with position.

Most applications of scene2d use rectangular actors (UI, platformers, top-down games…) where the point in the center of the rectangle (your suggested origin) is really used only for scaling and rotation, all position/size related logic deals with the rectangle’s corners.

This is not a design issue, the design here is sound. One could argue that it shouldn’t be called origin but something like “transformCenter”, as “origin” really does suggest something related to position, but changing that now would break too much code. The documentation on this could be improved though.

1reaction
Darkyenuscommented, Oct 17, 2018

You keep assuming that scene2ds purpose is to be used like a 3D scene-graph. If that were the case, you would be 100% right. But this is not the case, as I have explained before. Changing this now would break virtually every class in the scene2d.[ui] packages.

How often people override setPosition […]

I don’t remember ever encountering that. I imagine that doing so will break a lot of existing code, so it can’t be used, in which case why bother with scene2d at all?

Major version increment is soon […]

Just because the next version is 1.9.9, it does not mean that next version must be 2.0.0. These dots are just version separators, not decimal points.

Read more comments on GitHub >

github_iconTop Results From Across the Web

[vtkusers] Problem with vtkActor->SetOrigin() - Kitware
However, when I apply SetOrigin(pos), my actor moves in the scene such > that ... But doesn't SetUserTransform() do that already... the vtk...
Read more >
Actor origin in scene 2d - libgdx - Stack Overflow
The position instead is always relative to the lower, left corner and is not affected by the origin. If you want to set...
Read more >
Does setScale() affect setPostion() and setOrigin()? - SFML
Any transformations are applied around the origin so rotations rotate around the origin (and that part - the position/origin - doesn't move) and ......
Read more >
"How do I ZScript?" - Page 25 - ZDoom forums
This function only alters the position but does not alter the ... If you want to change an actor's position in the world,...
Read more >
Actor's location not updating with it's static mesh component
Hi Guys, I have an issue with one of my actors where the location of the actor doesn't change in-game when the actor...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found