tags:

views:

287

answers:

1

I'm working in a view based application and am trying to find some code that will let me grab some pixel colors from one of my images and use it for collision detection against one of my UIImageViews but haven't had any luck finding anything on this subject. So if my UIImageView for my player collides with the UIImageView of my map && collides with the color black in my image that's placed inside of my map view... then run collision code... or something along those lines.

A: 

Is your question about getting the pixel color, or about doing collision detection?

If you want to get the pixel color, I'm not sure there's an easy way to do it - you may have to mess with your current graphics context to get it, and nothing is coming up in the docs.

If it's just collision detection you want to do, take a look at UIView's convertPoint:toView: and convertPoint:fromView: methods. They let you take defined points within a given view and get their equivalents in other views. With some basic math on the resultant points, you could theoretically do some pretty good collision detection without having to worry about pixel colors.

Tim
In this article it explains about the color maps I'm trying to detect and grab a certain pixel from an image to use for my collision to achieve pixel perfect collision detection.http://www.30daygame.com/2009/04/11/how-the-map-works-or-a-guide-to-platforms/
You should probably look into the OpenGL framework for the iPhone - it looks like that's what they're using at 30daygame, and unfortunately I don't know enough about OpenGL to be of more help. Sorry!
Tim
It's fine. I guess I'll try looking into OpenGL, but I to haven't touched it yet.