Does sprite component support frames with different dimensions? #824
-
|
Hello, I'd like to ask if it's possible for frames within a single sprite to have different dimensions without being stretched. Currently, it seems the For example, if // Assuming texture is 100x100 for simplicity
k.loadSprite("my_sprite", "texture.png", {
frames: [
k.quad(0, 0, 50/100, 49/100), // frame_0
k.quad(0, 49, 50/100, 45/100), // frame_1 (gets stretched)
],
anims: {
"play": { from: 0, to: 1, loop: true, speed: 1 },
},
});Is there a recommended workaround or a specific part of the codebase I could modify to make each frame render at its original aspect ratio? Thank you for your great work on Kaplay |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
|
I don't think this is ever going to be added, having different-sized frames that cause different-sized bounding boxes/colliders. The quad doesn't have anything to do with physics really, it just defines the range of uv inputs that go to the GPU so that it pulls the part of the texture that you want. Whether it gets stretched is controlled by the rest of the rendering code. For example, the scale component changes the screen quad that it gets drawn into, but doesn't change the texture quad, so the chunk of the texture being rendered gets stretched. If you want it to change size I suggest making two different sprite ids and switching the entire sprite instead of just playing a new animation. |
Beta Was this translation helpful? Give feedback.
I don't think this is ever going to be added, having different-sized frames that cause different-sized bounding boxes/colliders. The quad doesn't have anything to do with physics really, it just defines the range of uv inputs that go to the GPU so that it pulls the part of the texture that you want. Whether it gets stretched is controlled by the rest of the rendering code. For example, the scale component changes the screen quad that it gets drawn into, but doesn't change the texture quad, so the chunk of the texture being rendered gets stretched.
If you want it to change size I suggest making two different sprite ids and switching the entire sprite instead of just playing a new animation.