eggborne Posted January 28, 2016 Share Posted January 28, 2016 I have sprites which are all anchored at 0.5 for x and y, and they are often "flipped" via (e.g.) someSprite.scale.x *= -1. Because their anchors are centered, they don't move immediately because of this. However, changing to a negative scale mucks with their size and coordinates, because now a 20px-wide sprite will report a width of -20px, and it also interprets changes to its position inverse to what they were before (sprite.x++ will cause it to move up on the screen). This makes sense and everything, but the sprites' movement and activity is not always related to their scale. I know there must be a simple way to make a mirrored "copy" of a texture which can be swapped out on a single sprite without having to change its scale from positive to negative constantly. Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted January 28, 2016 Share Posted January 28, 2016 And that's my moment of glory! I had the same problems and I knew that someone will need that too Yes, you can create/rotate a flipped texture now! http://ivanpopelyshev.github.io/examples/index.html?s=demos&f=texture-rotate.js&title=Texture%20Rotate Use this, latest development version of pixi: https://github.com/ivanpopelyshev/examples/blob/gh-pages/_site/js/pixi.js This build isnt even in github yet, you have to take that version or build it from "dev" branch on github var flipX_Texture = new PIXI.Texture(texture.baseTexture, texture.frame, null, null, 12); var flipY_Texture = new PIXI.Texture(texture.baseTexture, texture.frame, null, null, 8); Textures arent actually flipped or rotated, its just trick with UV's (webgl) and coordinate systems (canvas) Quote Link to comment Share on other sites More sharing options...
eggborne Posted January 28, 2016 Author Share Posted January 28, 2016 Thank you so much! So you're telling me this "flipped" texture won't have any weird baggage left over from from being flipped? It will be just as though it were a new image completely? Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted January 28, 2016 Share Posted January 28, 2016 3 minutes ago, eggborne said: Thank you so much! So you're telling me this "flipped" texture won't have any weird baggage left over from from being flipped? It will be just as though it were a new image completely? Yep. The only problem you can encounter possibly, if the image were trimmed by texturepacker on different number of pixels from two sides. I dont know will it work in that case or not, I didnt test it. Quote Link to comment Share on other sites More sharing options...
eggborne Posted January 28, 2016 Author Share Posted January 28, 2016 I have the most anal sprite sheets you've ever seen so I don't think that will be a problem. Thank you again! ivan.popelyshev and qdrj 2 Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted January 28, 2016 Share Posted January 28, 2016 5 minutes ago, eggborne said: I have the most anal sprite sheets you've ever seen so I don't think that will be a problem. Thank you again! Have a pony. Can you show me the spritesheets so I confirm that they're "most anal"? Quote Link to comment Share on other sites More sharing options...
Gerente Posted March 25, 2018 Share Posted March 25, 2018 Lol, yes, lets see if they are really the "most anal" sprite!. Flip the texture with rotate=8 is an option, but what happen with the animatedSprite?. If I load an animatedSprite with 10 frame looking to the left side, changing the texture rotation would require to add 10 more rotated textures!. And this is just an example, it could be more. scale.x = -1 look like the solution BUT it change the position texture inside the object!! Any idea for this? Thanks Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted March 25, 2018 Share Posted March 25, 2018 Yes, flip them all. Textures are lightweight objects. 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.