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 / Easy detection of colliding sprites?

Author
Message
hakimfullmetal
9
Years of Service
User Offline
Joined: 17th Feb 2015
Location:
Posted: 19th Aug 2015 04:43
Hello everybody. Just a quick question.
Just wondering, is there any 2D command for detecting collision between sprite, in which the command will provide which sprite is colliding with a specified sprite?

Let's say that I have 1 player sprite, and 10 other object sprite.
I want to use a command so it will tell me which sprite is colliding with my player sprite.
Now the normal way is to cycle through all the 10 object sprites and checking their collision with my player sprite one-by-one, but I imagine this would be slightly slow if there's too many sprites to check.
But with a built in command to do just that, it might be faster.

Is there such a command?
Fluorescent
FPSC Reloaded TGC Backer
18
Years of Service
User Offline
Joined: 1st Aug 2005
Location: Stockholm, Sweden
Posted: 19th Aug 2015 18:34 Edited at: 19th Aug 2015 18:34
You might be able to use the physics commands for that. Check them out here.
http://www.appgamekit.com/documentation/Reference/2DPhysics.htm

Altough they require you to use physics for the collision.

Otherwise you might have to loop through a subset of your sprites and only check the ones that are close to the sprite you want to track more closly.
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 19th Aug 2015 18:48
see GetSpriteFirstContact

AGK (Steam) V2 Beta .. : Windows 10 Pro, 8.1 Pro 64 Bit : AMD (15.7.1) Radeon R7 265 : Mac mini OS X 10.10 (Yosemite)
hakimfullmetal
9
Years of Service
User Offline
Joined: 17th Feb 2015
Location:
Posted: 21st Aug 2015 19:25
I see, thank you

Login to post a reply

Server time is: 2024-04-19 07:09:35
Your offset time is: 2024-04-19 07:09:35