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

Rotate around anchor property #93

Closed
wants to merge 3 commits into from
Closed

Rotate around anchor property #93

wants to merge 3 commits into from

Conversation

floatdrop
Copy link
Contributor

PIXI.Sprite have nice anchor property, but DisplayObject haven't. This creates difficulties to create camera, that rotates around the player (#83). Needs to be checked twice.

@floatdrop
Copy link
Contributor Author

Bump here.

@GoodBoyDigital
Copy link
Member

Hey @floatdrop,

This code is great - it kind of makes the sprite anchor and the display object anchor behave differently though, which could lead to confusion. What are peeps thoughts on this?

@Fishrock123
Copy link
Contributor

Shouldn't the Sprite's anchor be it's inherited DisplayObject anchor?

@floatdrop
Copy link
Contributor Author

Well, it's a bit tricky, @Fishrock123. Sprite anchor use percentage to set an origin - an this is awesome feature, that I like. DisplayObject anchor must be in pixels (because DisplayObject don't know about width of itself). But in other angle of view, DisplayObject can't get percentage anchor, because DisplayObjectContainer is inherits from DisplayObject and it's have'nt texture to count pixels from! This leads to two ways of solving this. First - get our code dirty by this:

    var ax = this instanceof Sprite ? 0 : this.anchor.x;
    var ay = this instanceof Sprite ? 0 : this.anchor.y;

Second: drop the percentage functionality from Sprite.
What you think, @GoodBoyDigital? (Also, I don't see, how sprite is rotated in WebGL, could you point it out for me?)

@Fishrock123
Copy link
Contributor

Why not just have sprite convert from percentage to pixels when set via setAnchor(PIXI.Point); or something?

EDIT: or even better: PIXI.Sprite.setAnchorByPercent(PIXI.Point);

@floatdrop
Copy link
Contributor Author

Seems working to me.

@floatdrop
Copy link
Contributor Author

Bump again. (Sorry for persistence).

@GoodBoyDigital
Copy link
Member

No worries @floatdrop !
I am working on a new build at the moment and will roll this in to the next update :)

@GoodBoyDigital
Copy link
Member

Hey @floatdrop just updated the pixi build..

a display object now has a pivot point.. I used your code and it works a treat 👍

Thanks!

@lock
Copy link

lock bot commented Feb 26, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked and limited conversation to collaborators Feb 26, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants