d13 Posted June 14, 2015 Share Posted June 14, 2015 Hey everyone... I'm trying to understand the difference between Pixi's `anchor` and `pivot`This is what I've been able to deduce so far... Anchor shifts the origin point of the sprite's image texture, using a 0 to 1 normalized value.Pivot shifts the origin of the sprite's x and y point, using pixel values. Is this correct - or brain-dead? Quote Link to comment Share on other sites More sharing options...
xerver Posted June 14, 2015 Share Posted June 14, 2015 That is correct. The anchor is the attachment point for a texture (normalized to the size of the sprite), the pivot point is the point around which an object rotates (in pixel values). Quote Link to comment Share on other sites More sharing options...
d13 Posted June 14, 2015 Author Share Posted June 14, 2015 That is correct. Thank you so much for that confirmation! Quote Link to comment Share on other sites More sharing options...
caymanbruce Posted December 21, 2016 Share Posted December 21, 2016 So pivot.set(x, y) just means setTransform(1, 0, 0, 1, x, y) in Canvas API? Quote Link to comment Share on other sites More sharing options...
xerver Posted December 22, 2016 Share Posted December 22, 2016 Kind of. Quote Link to comment Share on other sites More sharing options...
caymanbruce Posted December 23, 2016 Share Posted December 23, 2016 5 hours ago, xerver said: Kind of. But I am still confused with the use of pivot in different coordination system. For example, I have a map which is a TilingSprite with origin at (0, 0) and it's larger than the canvas size. I want my player sprite in the center of the canvas and it can move around the map. So I use a camera to do that. Suppose my camera is at (camera.x, camera.y) of the map, now the coordination system still has origin at (0, 0). Now if I set my map position: map.position.set(render.view.width / 2, render.view.height / 2); and change its pivot: map.pivot.set(render.view.width / 2, render.view.height / 2); It will shift the map origin to the center of the canvas and now the new (0, 0) is actually (render.view.width / 2, render.view.height / 2)? Why can't I just set pivot point as (render.view.width / 2, render.view.height / 2) without shifting the position? If I don't set the position to (render.view.width / 2, render.view.height / 2) the map stays at the same place and a pivot set doesn't have any effect. If I scale the map it will still scale to the original (0, 0). More confusing is that when I move my player my camera moves. But setting the map's pivot to the center of canvas still works as before. How does pivot translate my coordinates when my player's actual (x, y) changes? Quote Link to comment Share on other sites More sharing options...
xerver Posted December 23, 2016 Share Posted December 23, 2016 Because pivot affects the *transform* of the object. That means position and rotation. Quote Link to comment Share on other sites More sharing options...
caymanbruce Posted December 23, 2016 Share Posted December 23, 2016 5 hours ago, xerver said: Because pivot affects the *transform* of the object. That means position and rotation. Thanks that really helps. I have found solutions for my game map. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.