How to offset Texture when Sprite.achor is not (0,0) [SOLVED]
See original GitHub issueThe logic of Sprite.calculateVertices()
is :
if (trim)
{
// if the sprite is trimmed and is not a tilingsprite then we need to add the extra
// space before transforming the sprite coords.
w1 = trim.x - (anchor._x * orig.width);
w0 = w1 + trim.width;
h1 = trim.y - (anchor._y * orig.height);
h0 = h1 + trim.height;
}
But I want to that logic like this :
if (trim)
{
// trim.x needs `* anchor._x`
w1 = anchor._x * trim.x - (anchor._x * orig.width);
w0 = w1 + trim.width;
h1 = anchor._y * trim.y - (anchor._y * orig.height);
h0 = h1 + trim.height;
}
Is there a way to do that ? or equivalent method ?
Issue Analytics
- State:
- Created 7 years ago
- Comments:5 (4 by maintainers)
Top Results From Across the Web
How to offset Texture when Sprite.achor is not (0,0) [SOLVED]
The logic of Sprite.calculateVertices() is : if (trim) { // if the sprite is trimmed and is not a tilingsprite then we need...
Read more >Tiled sprite with scale factor & anchor stretching does not work ...
Quick and dirty answer to this: Change the pixels per unit import setting on the sprite to scale it as desired, then set...
Read more >PIXI.Sprite - PixiJS API Documentation
The anchor sets the origin point of the sprite. The default value is taken from the Texture and passed to the constructor. The...
Read more >How to Sort 2D Sprite Rendering Order ~ Godot Tutorial
Learn how to automatically organize your sprite rendering order ... Timestamps: 0 : 00 The Sorting Problem 1:18 Y-Sort Node Solution 2:08 ...
Read more >Three JS issue with texture offset and repeat for positioning ...
Solved it. For future reference, this is what I ended up with to get a sprite sheet working with a texture atlas in...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
If don’t change current logic in Sprite , there is another way to do same thing:
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.