Character collisions/ draw coordinates

Sep 25, 2011 at 12:37 AM
Edited Sep 25, 2011 at 4:06 AM

Hey i really like this tool.

 

I have a question about character and related things to said character.

How would One go about drawing the character at The maps pixel coordinates behind/infront/on a specific layer rather than the sprite being drawn on screen pixel coordinates?

How would i do collisions? and would farseer physics work with this?

 

Thanks bob

 

Edit1:  i think i got the draw Coords working correctly / not sure about cam following / just not the layer and the rest.

Coordinator
Sep 25, 2011 at 11:55 AM

To render graphics between layers, you can hook handlers to the BeforeDraw and/or AfterDraw events of the Layer object. Have a look at the demo code, specifically within the LoadContent method here.

To convert the position of your objects from map pixels to the actual coordinates required to render on screen, you need to take the viewport into consideration by subtracting it's location coordinates. Also, in case you render from an offset other than the top-left corner of the screen, you need to add in that offset as well. I suggest you have a look at this discussion.

Regarding collisions, have a look at this discussion. As for using Farseer physics to do collision detection, it is probably overkill, unless you need realistic physics such as boxes bounding and tumbling about. If you do go for a physics engine though, you need to find a way to make objects interact with the map.