Draw Line

Get help using Construct 2

Post » Thu Jul 13, 2017 7:11 pm

Hey guys, I just wanna know how can I draw a line automaticly in construct! I mean I wanna a line be drawn in center of layout. I have seen "Canvas" Plugin, but I don`t know how can I work with that. anyone here can help me?
B
2
Posts: 2
Reputation: 154

Post » Thu Jul 13, 2017 9:00 pm

i believe i read something about canvas support in full version, however, being as you know where you want your line, why not just make a sprite? something rectangular, 5x100 or something like that, and disable initially visible, when you want the line drawn , set visible.
maybe try using something like,

set sprite width to distance (origin.x,origin.y,mouse.x,mouse.y)
set sprite angle to mouse.x, mouse.y

this will set the length or width of the sprite to the distance between your start point and where you clicked.
B
28
S
14
G
1
Posts: 148
Reputation: 3,218

Post » Thu Jul 13, 2017 9:38 pm

No, I meant, I wanna make a line in layout and that automaticly Stretch out anytime. and after an evnet (like after 3 seconds) that line will be tilted. So I don't think so your method can help me.
B
2
Posts: 2
Reputation: 154

Post » Sun Dec 10, 2017 7:59 pm

sorry for the late response, if you havent figured it out yet, maybe something along the lines of on trigger set x to x+ Mouse.x2-mouse.x1
then have 2 variables to click a start and finish point, so that it changes the sprites length to the distance of the sprite, plus the difference in distance between the two clicks.
so as if it was a 4 unit box, and you clicked at 4 and 7 pixels hypothetically, the code would run 4 + (7-4) = 4+(3) and set the new length to 7. but even if you dont click exactly where the box ended the math would add up even if you clicked at 17 and 20. however if you clicked at 20 and then 17, the math would say, set x to 4 + (17-20)= 4+(-3) and set new length to 1, as 4 -3 is 1, successfully shortening your line.
an easier way to do this , though i dont know its applicable in your situation, would be to add a slide bar, and set sprite.x to slidebar.value
B
28
S
14
G
1
Posts: 148
Reputation: 3,218

Post » Sun Dec 10, 2017 8:00 pm

that may adjust position instead of size, instead of set x set width/length
B
28
S
14
G
1
Posts: 148
Reputation: 3,218


Return to How do I....?

Who is online

Users browsing this forum: JoniArtha and 5 guests