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 / selection box

Author
Message
american eagle
17
Years of Service
User Offline
Joined: 2nd Aug 2007
Location:
Posted: 7th Nov 2009 01:34
hey I am making a function for mouse selection box
i want the sprites within the box created by dragging the mouse to be selected.... i have many ideas how to do this but i want to hear some more to pick the most efficient one

the most important thing for me is that this function may be used in any program not just in one.. which means there must be a way of telling any program which of his object is selected without changing the function every time to let it know what objects are in the program...

thxxx i hope for nice suggestions
Hassan
15
Years of Service
User Offline
Joined: 4th May 2009
Location: <script> alert(1); </script>
Posted: 7th Nov 2009 06:38
i don't really get what you are asking for, but if you want to select sprites ( buttons ) just make a 1x1 alpha channeled image and keep positioning it on the mouse position, then check collision between it and the button sprite
if you are talking about selecting objects, take a look at dbPickObject();

american eagle
17
Years of Service
User Offline
Joined: 2nd Aug 2007
Location:
Posted: 7th Nov 2009 10:10
nope you didn't get my point i explained it well enough i guess but i will try to explain a little more... what i want to is to make a selection box and i mean by that when you press the left mouse button and drag it will create a box.. and i want all the sprites within this box to be selected
Hassan
15
Years of Service
User Offline
Joined: 4th May 2009
Location: <script> alert(1); </script>
Posted: 7th Nov 2009 10:46 Edited at: 7th Nov 2009 11:00
oh..
then just save the mouse position where you clicked first time and stretch the sprite to the next location, like:

something like that ( or just use dbBox.. )

edit: and to select sprites within the box check if the stretched sprite is colliding with any other sprites and save them in a structure or a vector.

american eagle
17
Years of Service
User Offline
Joined: 2nd Aug 2007
Location:
Posted: 7th Nov 2009 13:53
nice option thx i have many ideas but urs is one of the ideas i will look into
cleonjones
14
Years of Service
User Offline
Joined: 24th Oct 2009
Location:
Posted: 8th Nov 2009 05:45 Edited at: 8th Nov 2009 05:46
I think the best way to check if sprites are selected is by comparing their X and Y coordinates to the ones defined by your selected area.

I think it'd be something like this:


With that you wouldn't have to use a sprite, you could just use a simple rectangle if you wanted to.

?
american eagle
17
Years of Service
User Offline
Joined: 2nd Aug 2007
Location:
Posted: 8th Nov 2009 12:32
yeah i thought of this and it seems the best when u use simple rectangle as u said and i think i'll go for it though Hassan's option is good when u want the rectangle to be a sprite not just simple box
cleonjones
14
Years of Service
User Offline
Joined: 24th Oct 2009
Location:
Posted: 8th Nov 2009 15:01
Well you can still have a sprite to represent the selection box, but you wouldn't have to worry about checking the collisions between the objects and the sprite

?
Hassan
15
Years of Service
User Offline
Joined: 4th May 2009
Location: <script> alert(1); </script>
Posted: 8th Nov 2009 15:15
cleonjones's code is better than mine, anyway

Login to post a reply

Server time is: 2024-10-06 01:23:37
Your offset time is: 2024-10-06 01:23:37