Selection Box Problems - Left button pressed issue?

I have a game with a selection box in and the selection box code works fine if it’s in a scene on its own, but when I take that code into the main game, it doesn’t work anymore. The problem might be because so many events are checking for left mouse button clicks? Is it bad to have lots of events looking for these left button pressed conditions? Is it maybe because there are so many events to check (around 100 in total now) that some events are being missed?

At the moment, my selection box looks for if the left mouse button is pressed and if it is, it continually redraws the selection box from the point you clicked to the current x,y position of cursor. Is there a better way of making this?

Any help at all is appreciated. :slight_smile: I haven’t managed to track down the issue and am stuck. : (

If you moved your code into another scene, maybe you didn’t declare variables used in the code, or it’s a problem of logic: the code doesn’t work under the conditions where it was pasted :confused:
Anyway, without the code, it’s hard to know :neutral_face:

I don’t think so, you have to draw it every frame with the right size. But you could not use one or few conditions to check the left-button click, and then use sub-events for other conditions?

I attached the code I’m using for the selection box (just copied it out of the game into a new project). I double and triple checked that required variables were declared and required objects existed, so I’m sure that is not the problem.

(the zip is project + required images)
selection box.zip (4.77 KB)
sbox example.gdg (71.9 KB)

It needs to be so complex :unamused: ? (I could not imagine the rest of the project/game), that could get you in trouble. I don’t know where it has to work, but it seems to works fine.
Try with a basic selection, maybe the selection code isn’t the problem, check this out:

box_selection.zip (3.36 KB)

I totally forgot GD has a drawer! Thanks for showing a very neat way of doing this. : )

I hate selection boxes - I had no idea how to make them, finally made one that worked and then it doesn’t work in the game, while all the rest of the game is working fine! :angry: Who needs to select player units anyway? :stuck_out_tongue: /rant

Thanks for you help Lizard! I will look for some piece of code that is causing logic conflicts. :slight_smile: