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.

Dark GDK / problem with sprite collision

Author
Message
american eagle
17
Years of Service
User Offline
Joined: 2nd Aug 2007
Location:
Posted: 18th Nov 2009 02:19
I'm making a card game and I made a mouse cursor from a sprite.. so it would be easier for me to select a card by checking collision between sprites.. the problem is that the dbSpriteCollision() function
seem to return always the ID of the background sprite!! even if the cards are in front and the cursor far from touching the background
i used dbSpriteCollision(CUSRORID,0) and I just needed it to return the selected card sprite

any ideas on this!? thx in advance
Marsh0
15
Years of Service
User Offline
Joined: 18th Mar 2009
Location:
Posted: 18th Nov 2009 08:54 Edited at: 18th Nov 2009 08:56
set the background as sprite 0 then check what number it is colliding with, if its any number higher then 0.



I just reread your post, if it always returns 0 then try actually checking to see if it impacted with another sprite. Instead of putting a 0 in actually put one of your sprite numbers. If you want all other sprites give it a variable name and put it into a loop.
american eagle
17
Years of Service
User Offline
Joined: 2nd Aug 2007
Location:
Posted: 18th Nov 2009 09:22
yeah I can do this but I just wanted to know why this happen cause it's much easier to do it without a loop...
anyway I'll do it the hard way I have another thing to ask.. anyone has a pixel perfect collision function ready for darkgdk??
Marsh0
15
Years of Service
User Offline
Joined: 18th Mar 2009
Location:
Posted: 18th Nov 2009 19:15
I have heard mentions of sparky collision never used it myself though. May be what your looking for.

http://forum.thegamecreators.com/?m=forum_view&t=100377&b=22
Cuddle Bunniezzz 12
15
Years of Service
User Offline
Joined: 14th Jan 2009
Location: Buffalo, NY
Posted: 18th Nov 2009 21:35
Well, you could do something where you create another sprite to replace the mouse, and if the mouse sprite is coliding with the card sprite, do a specific action.

I think the code would be something like this:



If you don't like to use your own sprite for a mouse, could could create a pixel using dbDot() to follow the mouse, yet have it's opacity set to 0, and use that as the collision checker. Not sure exactly how to do that though.

http://www.darkgdk.us/ <- New community for DarkGDK coming soon!
Mireben
16
Years of Service
User Offline
Joined: 5th Aug 2008
Location:
Posted: 18th Nov 2009 21:48
Sparky's is for 3D, not for sprites.

The dbSpriteCollision() function can return only one number, so if the mouse sprite is overlapping several sprites (in this case, background and a card), then it returns the first collision it finds. If it gives you the background sprite ID, then obviously it doesn't consider the drawing order, what is on top and what is below. You will need to check against all the cards in a loop.

Login to post a reply

Server time is: 2024-11-20 09:38:38
Your offset time is: 2024-11-20 09:38:38