XNA + Camera2D + PerPixelCollision

Started by
4 comments, last by LordRhys 11 years, 2 months ago

Hi, everybody smile.png

For some time playing with XNA 2D. I implemented Camera2D from tutorials: it have move, rotate and zoom. It work pretty good with simple Rectangle collision. But then I try to do PerPixelCollision with zoom - boom, game crashes. On method Texture2D.GetData(Color[]). Error says: The size of the data passed in is too large or too small for this resource. But if I dont zoom - works perfectly.

Maybe somebody have same problem?

I adding project (visual studio 2010), maybe somebody will know what doing not right. All logics about game objects is in Entity, in end of UpdateEntity, and next method is PerPixelCollision

Uh, was forget to add project. Now tried, and didn't let to add, so there is link: https://www.dropbox.com/s/gimojdfhdzspzpl/TestGame.7z

Advertisement

I don't use XNA at all, but, isn't XNA dead? (Miscrosoft isn't supporting it anymore, last I heard).

I'm sorry I don't have an aswer, but I'm curious as to why you're still using XNA :)

a WIP 2d game engine: https://code.google.com/p/modulusengine/

English is not my first language, so do feel free to correct me :)

I don't use XNA at all, but, isn't XNA dead? (Miscrosoft isn't supporting it anymore, last I heard).

I'm sorry I don't have an aswer, but I'm curious as to why you're still using XNA smile.png

Just today saw that XNA is dead, but for learning if think get some good experience from it :) Later what I learn now with XNA, I will able to adapt to other API ;)

I don't use XNA at all, but, isn't XNA dead? (Miscrosoft isn't supporting it anymore, last I heard).

I'm sorry I don't have an aswer, but I'm curious as to why you're still using XNA smile.png

Just today saw that XNA is dead, but for learning if think get some good experience from it smile.png Later what I learn now with XNA, I will able to adapt to other API ;)

Check out http://www.monogame.net/

Based on XNA, supports almost any platform you can think of and has an active development community.

Also - do add your project or the code that's breaking down... very hard to debug otherwise :)

Hello Plutonium,

i haven't looked at your code but have you tried calculating the collusion before you draw everything zoomed in?

so after calculating you do the math for the zoom.

I agree with precious roy, the collision code should come before you ever get to the render code, the zoom function of your camera should be part of your rendering not your update. While you may have the change from normal display to Zoom and back in your update code the actual change in the screen output is part of render. I don't use perPixel collision, I use a collision radius system with an origin point but my collsion code works Zoomed or not.

This topic is closed to new replies.

Advertisement