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.

Newcomers DBPro Corner / Sprite Collision Problem (DBP)

Author
Message
Mirthin
21
Years of Service
User Offline
Joined: 13th Oct 2002
Location: Land of the Rising Haggis
Posted: 15th Oct 2006 23:16
Hi there.

I'm having a problem creating buttons for a graphical interface. I'm trying to make a sprite follow the mouse cursor, and when it collides with a button, it should return the sprite number of the button. It doesn't seem to change though, it just stays on sprite 1 which is the sprite which covers the whole screen and provides a border.

Zergei
19
Years of Service
User Offline
Joined: 9th Feb 2005
Location: Everywhere
Posted: 16th Oct 2006 01:15
That is because it's detecting the background sprite, and once it detects it, it stays with that sprite as collision. You should paste the background image instead of using a sprite.

Further on my stuff at...
Mirthin
21
Years of Service
User Offline
Joined: 13th Oct 2002
Location: Land of the Rising Haggis
Posted: 16th Oct 2006 02:33
Thank you very much for the help, but it seems that there's still a problem. The Sprite Collision function is now just returning 0.

Here is my code now.



I'm also getting a kind of white flickering effect now, but that might just be my graphics card.
spooky
22
Years of Service
User Offline
Joined: 30th Aug 2002
Location: United Kingdom
Posted: 16th Oct 2006 02:44
You are getting confused with sprites.

Pasting sprites just pastes a copy of the sprite, but the sprite will still be in its original place.

So just pasting sprite 3 at mouse coords is not enough. You need to move sprite 3 to mouse pos aswell.

In fact you should not need to paste all the button images as they will be automatically upkept and drawn by DBpro.

So in main loop, you should just paste sprite 1 (for the backdrop), move sprite 3 to mouse position, then do your collision check.

Doing a SPRITE command before main loop, sets things up so it gets drawn every loop automatically.

Boo!
Mirthin
21
Years of Service
User Offline
Joined: 13th Oct 2002
Location: Land of the Rising Haggis
Posted: 16th Oct 2006 02:52
It's working fine now. That's absolutely excellent spooky, thanks again for helping me out!

Login to post a reply

Server time is: 2024-09-25 11:32:09
Your offset time is: 2024-09-25 11:32:09