Not logged inGosu Forums
Forum back to libgosu.org Help Search Register Login
Up Topic Gosu / Gosu Exchange / Transparent collision check problem
- - By kuehkookies Date 2012-01-24 03:27
Hello,

After drilling with the Gosu and Chingu environment, now I stuck in this problem. I've made a sprite, implement it to the game, and I got the sprite having incorrect collision check. I've read the documentation of related problem (in this case, the Chingu::GameObject, Sprite and also I've read TexPlay docs) then I found the cache_bounding_box is the culprit. It makes the sprite looks like hanging in the air rather than falling down to lower platform. Images in attachment.

Can someone explain how to get rid of the transparent part of the sprite?
Parent - - By Spooner Date 2012-01-25 00:33
No, the problem is that Chingu collisions are rectangular (bounding box) or circular, so they will have that effect. Pixel-perfect collisions are very rare and are often glitchy (games generally simplify collisions shapes significantly). If you need very accurate/complex collisions, the best option is to use Chipmunk, rather than Chingu, to manage your collisions.

You need to use a smaller bounding box/circle than the sprite to calculate collisions. That is, a sprite that covers the parts of the person that are always solid, not that covers the person and all the space around them where arms and legs could be. Just making the bounding box half the width would probably work for you in this case.
Parent - By kuehkookies Date 2012-01-25 06:44
I've done resizing bounding box to make collision properly (I made it to 40% of sprite's width) and it works as I expected. Also, I've tried some objects (projectile, sword animations and 'destructible' objects) to ensure they're working properly.

This makes sense, and gives me some other ideas to build a platformer game.
Thanks for your explanation.
Up Topic Gosu / Gosu Exchange / Transparent collision check problem

Powered by mwForum 2.29.7 © 1999-2015 Markus Wichitill