xna - Dynamically alter or destroy a Texture2D for drawing and collision detection -
I am using XNA for 2D project, I have a problem and I do not know how to To solve. I have a texture (an image) that is drawn on the screen for example:
| +++ | +++ | | --- | --- | | +++ | +++ | Now I want to be able to delete part of that structure / image so that it looks:
| +++ | | --- | --- | | +++ | +++ | So that the collision now also works for the new image.
Which method would be better to solve this problem:
- Swap the whole texture with another texture, which is transparent in places where it is destroyed has given.
- Use some sieve with Streetbatch.Dra (serroctengel, destinationrectengel), drag and drop desired rectangles, and collide
- Divide the texture into 4 small textures, each of which It will be responsible for detecting its drawing / collision.
- know about t
Any help would be appreciated. Let me know that you need more clarification / example.
Edit: To illustrate, I will provide an example of usage for this. Imagine a 4x4 piece of the wall, which is shot on, 1x1 part of some of it is destroyed.
I third option:
3 - Divide the texture into 4 small textures, each of which will be responsible for its own drawing / collision detection.
It is not difficult to do this; Actually this tile's structure is similar, however, you have to change your code to fit this approach. Get a little more information about tiles: How to use it to create more games and book tile and game worlds
No .. A different image is bad in every different situation. If you need to change the texture? Will you remake everything again?
2 - Use some sieve with spritebatch.drow (sourcerectangle, destinationRectangle) to drag the desired rectangles, and also check conflicts Unfortunately This does not work because spritebatch.Draw only works with rectangles: (
4 Use some other smart-asses the way I do not know.
I can not imagine any magic. Perhaps, using the second image to create masks But this is very processing-expensive.
Comments
Post a Comment