Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / Pixel-perfect sprite collision?

Author
Message
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 4th Mar 2014 22:11 Edited at: 4th Mar 2014 22:31
Trying to finish up my fighting game this week but unsure how to go about doing the collision. I thought maybe setting the sprite shape to polygon I'd be able to get close enough results, but it appears to ignore the sprite's offset if you flip the sprite.

The Daddy
15
Years of Service
User Offline
Joined: 13th Jan 2009
Location: Essex
Posted: 4th Mar 2014 22:34
Phaelax

You can change the offset i believe?

If you have already done this, then the alternative is to have your player have 'invisible' physics sprites under the collision parts and the collision detected against these! (Make sure your player that is 'seen' is not also checking for collisions as this could be confusing!

The user never sees them but the collisions can be pixel accurate if positioned well!

www.bitmanip.com
All the juicy you could ever dream of!
Digital Awakening
AGK Developer
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Sweden
Posted: 5th Mar 2014 12:48 Edited at: 5th Mar 2014 12:49
Collision boxes as The Daddy describes them is usually how fighting games are made. Then you will know what part of the body was hit.

xGEKKOx
AGK Master
15
Years of Service
User Offline
Joined: 7th Dec 2008
Location: Italy
Posted: 5th Mar 2014 13:18
You can also intersect the 2 sprites and face the side of the hit to get the x,y of the point.
Anyway, in the fighting games is used the second sprite with the mask of the body and the arm/leg/foot to get the hit.

If you want to use only normal pixel perfect collision use:
agk::SetSpriteShape(sprite, 3);

And you will have a polygon shape.


Long life to Steve!
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 5th Mar 2014 17:29
I ended up using polygon shape, which I have to set every time an animation frame changes. Not sure the kind of impact that can have, but when my animations only run at 8fps in a game that was originally designed to run on a 7mhz computer, I think I'll be ok. I've only configured the interaction for a single attack so far, but it looks ok.

Quote: "You can change the offset i believe?"

Of the collision? Changing the offset of the sprite in conjunction with flip sprite was causing problems. I worked around it by keeping track of my own offset variables when positioning.

Login to post a reply

Server time is: 2024-11-25 03:51:54
Your offset time is: 2024-11-25 03:51:54