selection box Rts

Get help using Construct 2

Post » Sat Jul 08, 2017 9:51 pm

hi there im making a game with a few rts elements in it and i wanna drag a box around my minions ive got it all works but the box looks awful when its stretched is there i way i can get around this?
B
15
S
5
Posts: 134
Reputation: 1,617

Post » Sat Jul 08, 2017 10:22 pm

Lol, check out 9patch.
Image ImageImage
B
168
S
50
G
169
Posts: 8,281
Reputation: 108,191

Post » Sat Jul 08, 2017 10:37 pm

thanks for the reply ill give it ago whatever it is :), another quick question im making a camera which follows sprite and it moves via me pressing wasd, how do i get it to stop moving when it reaches any of the sides and always keeping sprite centre of screen so when i move in opposite direction it will start immediately?
B
15
S
5
Posts: 134
Reputation: 1,617

Post » Sat Jul 08, 2017 11:11 pm

Remove the scroll to behavior, and learn how to use scrollx, and scrolly.
Research lerp, clamp, and dt, expressions also.
Image ImageImage
B
168
S
50
G
169
Posts: 8,281
Reputation: 108,191

Post » Sat Jul 08, 2017 11:35 pm

ahhh okay, that's doable just thought it might be easier with scroll to :) thanks a bunch for all your help :)
B
15
S
5
Posts: 134
Reputation: 1,617

Post » Sun Jul 09, 2017 12:00 am

@newt sorry despite how much i research into it and look at it none of it really makes sense, as to compare the positions you would still need to know the position between middle of screen and the edge but if your changing screen sizes or layout sizes then the middle position would change right ?

no problems i worked it out im still using scroll to but setting position to scrollx and scrolly so it will always be centre event if camera stops moving
B
15
S
5
Posts: 134
Reputation: 1,617

Post » Sun Jul 09, 2017 3:50 pm

i was wondering if someone could help me with this code in image, http://imgur.com/a/wsYPW

this is using a code from a youtube video tutorial on rts selection box, the problem with the code is he changing the sprites animation which isnt viable for as ive got to many animations to add selection box to and would mess up animations in progress.

the problem ive got with the code atm is not all demons are being selected unless i drag over them slowly and once they are selected if i decide to make selection box smaller they are all still selected, ive tried a few methods to fix this but nothing is really coming to mind can anyone help me please?

the selection box is 9patch if that means anything with the edges being tiled and filling being stretched middle of box is transparent
B
15
S
5
Posts: 134
Reputation: 1,617

Post » Mon Jul 10, 2017 9:04 am

Can anyone possible help?
B
15
S
5
Posts: 134
Reputation: 1,617

Post » Mon Jul 10, 2017 11:33 am

Besides that i (personal) think that creating that selection box just to destroy it a little moment later is a big waste.
The creation process is not that performant and and you will run into a difficult logical flow because of 'cant select a just created object before the next top level event'. Now, that last one you solved in an elegant way, still, it is a fix.

Just set it visible/invisible when you need it. Doing it that way, you can still check for overlaps after the mouse is released.

If you insist on that create/destroy process, then you have check for overlaps before you destroy the selection box.
The selection box is alive in event 420.

So just add to event 420.

Pick all Demons
...... action ... set selected to false <--- just reset the situation for all
.......sub event ... Selection box Is Overlapping Demons <---- more performance then the other way
.............action ... set selected to true
.............action update something visual so you can see that they are selected
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950

Post » Mon Jul 10, 2017 12:15 pm

@99instances2go thank you for replying , i'm happy to set to invisible,

so maybe

pick all demons
if mouse button left down - selected to false
blank sub event - set selection box to visible
subevent selection box overlapping demons - set selected to true
create unit selected demon.x + demon.y
pin unit selected to demon.x + demon.y
B
15
S
5
Posts: 134
Reputation: 1,617

Next

Return to How do I....?

Who is online

Users browsing this forum: Fradno, odiusfly and 24 guests