Selection box

Get help using Construct 2

Post » Thu Jul 05, 2012 1:55 am

Does anyone know how to make a selection box?like those that you have to click and drag with the mouse in strategy games...
thanks
B
16
S
5
G
1
Posts: 43
Reputation: 1,787

Post » Thu Jul 05, 2012 3:06 am

B
48
S
15
G
6
Posts: 795
Reputation: 12,035

Post » Thu Jul 05, 2012 3:06 am

You can save the position you start clicking in two variables, then set the create a sprite and set it's size to the distance between the mouse position an those variables.

Like this: SelectionBox.capx (r97)

Edit:
Better version:
SelectionBox2.capx (r109)Nimtrix2012-11-10 03:32:27
B
27
S
8
G
8
Posts: 903
Reputation: 8,452

Post » Thu Jul 05, 2012 4:39 pm

the only problem with this kinda thing is you dont want the sprite used for the selection box to stretch. If you make a 1 pixel thick hollow square on an image then stretch that sprite to twice its original size then that 1 pixel thick border becomes 2 pixels thick.

Maybe not a huge problem... possibly a very a big problem depending on the project. Either way it looks bad

The way its normally drawn is with frame images. 1 for each corner 1 for each side and 1 for the middle which is usually tiled not stretched. Not an easy solution to setup in c2 tho
B
13
S
5
G
2
Posts: 306
Reputation: 3,262

Post » Thu Jul 05, 2012 4:55 pm

@aridale

Yeah I see the problem, but if you use a single coloured image with opacity set down it looks OK in my opinion. You don't get any border around the selection though.
B
27
S
8
G
8
Posts: 903
Reputation: 8,452

Post » Sun Jul 15, 2012 8:06 pm

thanks,guys
B
16
S
5
G
1
Posts: 43
Reputation: 1,787

Post » Tue Jul 17, 2012 10:19 pm

But i have a little problem,when i try making the following event:

If units collide with selection box - units variable change to selected

but the units just get selected when i directly click them,but not when i drag the box to them

any ideas?
B
16
S
5
G
1
Posts: 43
Reputation: 1,787

Post » Tue Jul 17, 2012 10:59 pm

I made this capx the first time I read this thread but didn't post it for some reason. It's an expanded version of Nimtrix's capx. I think I had that same problem that you're talking about at one point but I can't remember the cause. If you can't get it working post up your capx or a screenshot anyway.

multipleSelection
B
54
S
28
G
18
Posts: 1,520
Reputation: 25,020

Post » Wed Jul 18, 2012 4:45 pm

that's just awesome,thanks
B
16
S
5
G
1
Posts: 43
Reputation: 1,787


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 1 guest