- Home /
Is it possible to slice a sprite in 2 in gameplay?
Let's say I have a wooden stock and a sword, and the touchphase-began and -end will tell me the length/direction of the slice, can I can the wooden stock sprite in 2 sprites? Just like in fruit ninja and similar games.
Answer by fafase · May 03, 2014 at 05:07 PM
Your texture has a map with bottom left at 0,0 and top right at 1,1. This is applied to the sprite as uv map.
If you have a cut get the start and end of that cut vector, find the intersection points with the texture, then normalize that position in the uv map coordinate.
Now you can create a new sprite using the texture from 0,0 to top new position and another from bottom new position to 1,1.
Your answer
Follow this Question
Related Questions
How to slice a sprite realime C# 3 Answers
Coding my own auto-slicer, getting "islands" of pixels at runtime? 1 Answer
Automatically Slice Sprite from Code 0 Answers
How can I implement the ability to 'cut' sprites into arbitrary shapes? 1 Answer
How do I access a texture slice's rect via scripting? 1 Answer