Sign in to follow this  

what type of collision detection should i use? (2d)

Recommended Posts

Hi I was wondering what the best way to do collision detection in my game is. I want to be able to add new levels into my game very easily (by say a few lines of code just importing the image of the level). I think I should use collision detection based off color, but I am not sure how I should go about it because I also need to know where the collision occurred. I think I came up with a solution, but I'm not sure if it will work yet. The way the collision detection system works is by looping through the pixels underneath the image (that needs to be checked) and checking if they are a certain color. I was thinking I could just put some logic statements in the loop and check for collisions within certain ranges ( say the first 50 pixels would be half of the top row of pixels then the next 50 pixels would be the second half of it). Am I thinking about this correctly or should I go about this a different way? Also I am not exactly sure how to collect pixel data in i use getData method for type texture2? or what methods do I need to know about? (note: i don't have any code yet I am just planning the game out)

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