Sign in to follow this  
alexzchen

How to set anchor for a TilingSprite

Recommended Posts

I set a anchor for a TilingSprite with this code:  mySprite.tileTransform.anchor.set(0.5,0.5); but it doesn't work, when I rotate(or scale) it, it's still base on the left top.

If I want rotate or scale a TilingSprite base on the center, how shoud I do?

Share this post


Link to post
Share on other sites

try with pivot like this : 
sprite.pivot.x = sprite.width / 2;
sprite.pivot.y = sprite.height /2;

or with anchor directly using : 

mySprite.anchor... and not mySprite.tileTransform.anchor (don't know what is tileTransform)

Edited by Velith

Share this post


Link to post
Share on other sites

mySprite.anchor.set() will change the position of tilingSprite,I only want rotate the texture, not the sprite.

mySprite.tileTransform.rotation += 0.1 

mySprite.tileScale.x += 0.1

I want this two operation base on the center, not top left

Share this post


Link to post
Share on other sites

rotation around specific point, you need origin , origin doesnt exist in pixi transform, it can be emulated by adding a value to both position&pivot. 

Why do we have pivot and not origin?

1. in difficult cases pivot is more useful and easy to understand what it means

2. math is easier for it

Share this post


Link to post
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.