png - Pygame collision detection, transparent border -


for pygame project, must detect collision betweeen various .png image move on screen.

i have put image inside sprite, , sprite inside group, use :

pygame.sprite.spritecollide(perso, zombie_group, false) 

however, sometime, image don't touch, pygame detect collision... due fact images png transparent borders.

the transparent border collide, , pygame detect :(

any idea stop transparent border colliding ?

ok sprite take image can't detect if on trasnparent bg or color bg, seeing rectangle right now.

if using irregular shapes , rectangle approximation not enough recommend using collide_mask check masks want

update

regarding performance tutorial :

there other ways this, anding sprite masks , on, way in pygame, it’s going slow. games, it’s better ‘sub-rect collision’ – create rect each sprite that’s little smaller actual image, , use collisions instead. faster, , in cases player won’t notice inprecision.


Comments

Popular posts from this blog

java - pagination of xlsx file to XSSFworkbook using apache POI -

Unlimited choices in BASH case statement -

apache - How do I stop my index.php being run twice for every user -