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 / [BUG] GetSpriteCollision

Author
Message
Muckypaws
AGK Developer
13
Years of Service
User Offline
Joined: 21st Oct 2011
Location:
Posted: 25th Apr 2015 00:30
Hi,

I believe there is a bug in GetSpriteCollision which reports a collision on two rectangles at the wrong point.

I have two sprites 32 x 32 pixels in size.

Sprite1 : X = 96, Y = 256, W = 32, H = 32
Sprite2: X = 128, Y = 256, W = 32, H = 32

Get Sprite Collision Reports a hit.

I think what is happening is that the check take the X and adds the width of sprite (96 + 32) = 128
However the bounding rectangle of the sprite actually occupies 96 -> 127 Pixels as the origin pixel counts at point 0. As a result I get false positive hits when two rectangles are next to each other (physically) but not actually touching.

[href]https://www.facebook.com/WonkyPix
http://www.wonkypix.com
http://www.appstore.com/jsecconsultancyltd[/href]
CJB
Valued Member
20
Years of Service
User Offline
Joined: 10th Feb 2004
Location: Essex, UK
Posted: 25th Apr 2015 03:15
If there is no gap between the sprites, I'd consider that a collision.

What happens if sprite 2 x = 128.001?

V2 T1 (Mostly)
Uzmadesign
Scraggle
Moderator
21
Years of Service
User Offline
Joined: 10th Jul 2003
Location: Yorkshire
Posted: 25th Apr 2015 10:07
That was my first thought as well. But after checking the help files, it does clearly say that the command checks for overlaps.

So, I agree. I think this ought to be considered a bug. Either that or if this is by design then the help files need amending .

AGK V2 user - Tier 1 & 2

Login to post a reply

Server time is: 2024-11-25 21:42:09
Your offset time is: 2024-11-25 21:42:09