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 / mouseclicking on sprites

Author
Message
Jedi Padawan
15
Years of Service
User Offline
Joined: 17th Jun 2009
Location: None of your business
Posted: 5th Jul 2009 02:14
how do i detect a mouse click on a sprite. I don't wan't to use

if mouseX()=1 and...

because my sprite is organic shape. Any way like a sprite collision method?
Clbembry
17
Years of Service
User Offline
Joined: 10th Dec 2006
Location: Minnesota
Posted: 5th Jul 2009 02:34 Edited at: 5th Jul 2009 02:35
You could get the coordinates of every pixel and check if the mouse is inside of it But I'm guessing there is a far easier way.

Maybe have an invisible sprite at the mouses position, and check if the invisible sprite is colliding with your sprite?

Jedi Padawan
15
Years of Service
User Offline
Joined: 17th Jun 2009
Location: None of your business
Posted: 5th Jul 2009 05:12
i have an invisible sprite at the mouse's tip.

but knowing where a sprite is doesn't help in the clicking part. i mean, is there a command that would help me know if a sprite was clicked on?
Clbembry
17
Years of Service
User Offline
Joined: 10th Dec 2006
Location: Minnesota
Posted: 5th Jul 2009 07:30 Edited at: 5th Jul 2009 07:30
you check if there is a collision between the invisible sprite and your organic sprite... I don't seem to understand? I don't do a lot with 2D, so is the collision ignore transparent parts of the sprite or not?

Jedi Padawan
15
Years of Service
User Offline
Joined: 17th Jun 2009
Location: None of your business
Posted: 5th Jul 2009 08:25
i found the solution but i have a question and the other threads aren't very clear.

what is a pixel perfect sprite collision and how do i go about using it?
Jedi Padawan
15
Years of Service
User Offline
Joined: 17th Jun 2009
Location: None of your business
Posted: 5th Jul 2009 08:27
i used this by the way for my program

Dream And Death
18
Years of Service
User Offline
Joined: 21st Feb 2006
Location: The circus! Juggling job, kids and DBPro
Posted: 5th Jul 2009 10:10
You need to simply place a 1x1 invisble sprite at the mouse coordinates each loop and check for a collision. There is plenty of pixel perfect collision code on this board, a quick search should find several functions.

"You get what everyone gets, you get a lifetime!" - Death, The Sandman Library

First you Dream, then you ... - Neil Gaiman, 2001
Jedi Padawan
15
Years of Service
User Offline
Joined: 17th Jun 2009
Location: None of your business
Posted: 5th Jul 2009 19:44
thanks. it was good help

[img]http://www.danasoft.com/sig/JediPadawan.jpg[/img

Login to post a reply

Server time is: 2024-11-25 04:25:21
Your offset time is: 2024-11-25 04:25:21