Sign in to follow this  
JuliusDegutis

XNA + Camera2D + PerPixelCollision

Recommended Posts

JuliusDegutis    377

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

Share this post


Link to post
Share on other sites
JuliusDegutis    377

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 ;)

Share this post


Link to post
Share on other sites
Capoeirista    3266

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 :)

Edited by Orangeatang

Share this post


Link to post
Share on other sites
precious roy    156

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.

Share this post


Link to post
Share on other sites
LordRhys    379

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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this