Posted: 29th Sep 2011 10:27
I'm interested in developing an app with AppGameKit, and I'm wondering if/how I can get pixel-perfect collision detection from a sprite. Basically, back in VB6 days one could get a long-integer color ID from any given point within an image, and I am looking for similar functionality within AGK----even returning whether or not the portion of the sprite is transparent or solid would work.

I know pixel-perfect collision detection is CPU expensive, but I only need to do it once the user performs an action and not every frame either.

Thanks!

EDIT: An alternative would be storing the data in a 2-dimensional array, but the problem there would be reading the data into the array...... because unless AppGameKit does compression on text files (that would store the data), the files themselves would be huge.... or I would have to come up with my own compression scheme myself...
Posted: 3rd Oct 2011 3:42
I don't think there is a way to do this in AppGameKit, you have to rely on the createspriteshape command. I already posted with a similar question a while back.
I agree a simple, check for transparency would be nice for collision, it would make more complicated shapes work just as well as simple ones. I can see the need for the shape in physics based apps, but not for anything else.
Posted: 9th Oct 2011 4:23
We decided to avoid this type of command as it is performance intensive on some platforms, and your app would literally crawl on some devices when it left the safety of your development machine. There are alternatives to the challenges of creating a collision system for your game that does not use the pixel data of images to create your shapes, and they are often much faster than the per-pixel method of detection. Did you know you can slice your landscape into strips, and then grand each slide a 'shaped collision mode' using Box2D commands which wraps them in simply geometry. The result is very fast physics based landscape collision that will remain fast across all devices. If anyone is interested in these different collision ideas, post here and maybe we can collect some ideas for a new guide or video article
Posted: 28th Oct 2011 22:32
how i can make this "shaped collision mode"?, i am making a jump and run game, ive coded all the character moves like walk, run, jump, but now, i want to make a function to check its "feet" collision with my scenery, there is a mode to check the collision with all the scenery (its a tiled level) or i need to check every individual sprite collision? , i dont now how to use collisiongroup .
Posted: 30th Oct 2011 2:10
A trick for advanced collision detection is to have separate colider sprites.
Make an invisible / transparent sprite and "track" your character with this new sprite, with the appropriate offset. You of course only need to check the "foot overlay" for collisions then.

Another performance booster is to use box collision for everything, then if this collision is true, process it further with per-pixel or other critical / specific testing.

For collision groups, set your background tiles in group 1, your platform tiles into group 2 , enemies into group 3 and so on. I think you can have 16 groups and when you test your "feet" you only test against group 2 in this case to see if he has collided with a platform sprite.

Cheers