alexzchen Posted March 12, 2020 Share Posted March 12, 2020 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? Quote Link to comment Share on other sites More sharing options...
Velith Posted March 12, 2020 Share Posted March 12, 2020 (edited) 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 March 12, 2020 by Velith Quote Link to comment Share on other sites More sharing options...
alexzchen Posted March 12, 2020 Author Share Posted March 12, 2020 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 Quote Link to comment Share on other sites More sharing options...
alexzchen Posted March 12, 2020 Author Share Posted March 12, 2020 let mySprite = new PIXI.TilingSprite(resources["testpic"].texture); mySprite.tileTransform.pivot.set(200,200); //200 is center position mySprite.tileTransform.rotation += 0.1 mySprite.tileScale.x += 0.1 ivan.popelyshev 1 Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted March 12, 2020 Share Posted March 12, 2020 (edited) It should work with pivot. maybe tileTransform.position.set(200,200) too Edited March 12, 2020 by ivan.popelyshev Quote Link to comment Share on other sites More sharing options...
alexzchen Posted March 12, 2020 Author Share Posted March 12, 2020 it does works when I set the position 200, thanks Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted March 12, 2020 Share Posted March 12, 2020 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 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.