0
votes

Currently, my Character uses a collision layer with pixel-Perfect. I added some objects like "doors" or "Platforms" in my game, but my character pass through them.

I think I could modify the collision layer each Update() with something like "merging". Merging the collision layer with every objects I suppose, but I don't know how to do it...

[edited] Q1 : how to merge some Texture2D in one ?

Thx for reading, hope you'll guide me.

2
There's still no answer, if i'm not clear enough, just tell me :xSharpnel

2 Answers

0
votes

You can achieve this using RenderTargets. Here's a related question on how to use them.

Basically, you can draw all your collision sprites to the render target, making a single texture out of multiple ones. You can do this on each frame if your collision layer changes often.

Hope this helps!

Edit: Here's the MSDN article on RenderTargets

More edits: Alternatively, you could check your per-pixel collision on each of the objects instead of merging them all into one. However, you would have to show some code in order to get help for that.

0
votes

You can merge Texture2D via the .SetData and .GetData -Methods

Be careful with the methods though, as they really eat framerate.