Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add setCenterPosition and other methods to Actor #2000

merged 1 commit into from Jun 20, 2014


Copy link

jrenner commented Jun 20, 2014

convenience methods for position Scene2D Actors, much like the new centering methods in Sprite

NathanSweet added a commit that referenced this pull request Jun 20, 2014
add setCenterPosition and other methods to Actor
@NathanSweet NathanSweet merged commit a1a4489 into libgdx:master Jun 20, 2014
@jrenner jrenner deleted the jrenner:actor-centerpos branch Jun 21, 2014

This comment has been minimized.

Copy link

nooone commented Jun 21, 2014

wooohoow! That was the 2000th PR! :D

@macmata macmata referenced this pull request Jun 27, 2014

This comment has been minimized.

Do you mind if I change these to setPosition(x, y, align) and getX/Y(align) where align is an int Align constant? This gives the flexibility of setting or getting any of the 4 corners, the 4 edge centers, or the center. This can look like:

import static com.badlogic.gdx.scenes.scene2d.utils.Align.*;
actor.getY(top | right);
actor.setPosition(100, 100, center);
actor.setPosition(100, 100, bottom | right);
actor.setPosition(100, 100, bottomRight);
actor.setOrigin(top | left);

I started doing this for origin and thought it could be done for the others.

This comment has been minimized.

Copy link

NathanSweet replied Sep 21, 2014

Updated previous comment.

We could also remove getRight() and getTop() in favor of getX(right) and getY(top). What do you think?

Hmm, one potential issue (that also setCenterPosition has) is dividing width or height by 2 may result in non-integer positions. I guess the user just can't use these methods if they don't want that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
3 participants
You can’t perform that action at this time.