How do I draw a line

Get help using Construct 2

Post » Tue Feb 21, 2017 5:15 pm

I used to be a guru in C2, but havent used it for 2 years, coming back I cant figure out for the life of me how to draw a line.

I have the canvas object added to the project. I dont know if this canvas object is part of C2, or some plugin I installed years ago.

Anyway, when I do Canvas-> Draw line from (20,20) to (200,200) with color "black" and line width 1.0

Nothing happens no lines are drawn.

How do you define which layer the canvas is drawn on?

Any ideas? Probably something really simple.
B
17
S
6
G
3
Posts: 370
Reputation: 3,942

Post » Tue Feb 21, 2017 5:23 pm

It's a third party plugin and it draws to itself. Maybe it's not big enough?
B
91
S
31
G
103
Posts: 5,235
Reputation: 67,756

Post » Tue Feb 21, 2017 10:05 pm

I am assuming that the drawing coordinates are relative to the canvas container thing, not the top left of the projects layout, as I center the layout (by "set scroll X/Y" to the center). I think its your plugin rojohound.
B
17
S
6
G
3
Posts: 370
Reputation: 3,942

Post » Tue Feb 21, 2017 10:17 pm

Yeah, it's relative to the top left of the canvas.
B
91
S
31
G
103
Posts: 5,235
Reputation: 67,756

Post » Mon Apr 17, 2017 12:16 pm

@R0J0hound
I'm actually having this same issue... I'm not using the latest beta of C2 though. Can you confirm that canvas is still working from R242 and up?

I tried drawing a line, and filling a path... and nada. Just blank :/

Cheers

*EDIT*
I removed the anchor behaviour I had on the canvas and the line started drawing... path still not filling but maybe I'm doing something wrong there. Well, using anchor certainly causes an issue at least, lol. I'll try moving it manually and see if the problem returns or not.

~Sol
Tired of crappy file hosts that are crappy? Get DROPBOX - https://db.tt/uwjysXJF
Moderator
B
81
S
34
G
40
Posts: 3,031
Reputation: 30,422

Post » Mon Apr 17, 2017 3:30 pm

@SoldjahBoy
Here's an example how to draw a filled polygon vs just a line. Hope it helps.
https://www.dropbox.com/s/z2tkfrxk211rv ... .capx?dl=0
B
91
S
31
G
103
Posts: 5,235
Reputation: 67,756

Post » Tue Apr 18, 2017 4:14 am

Thanks @R0J0hound

I actually figured out what I was doing wrong but will take a look at your example anyway since you probably do it better ;)

I am still having one issue though... if I move the canvas at all during runtime, it moves/draws in an unexpected way. I have made an event that simply places the canvas to viewportleft and viewporttop (also tried using my camera obects coordinates as another way) but the canvas sems to move *beyond* the intended location... as in, when i move down, the canvas seems to move down (or right) as well but PLUS extra distance. The further I move, the more out of whack it gets. Any idea why it's not setting the position to viewport? I'm clearing the paths and lines every tick and redrawing on it, so I don't think it's a case of misaligned buffer.

~Sol
Tired of crappy file hosts that are crappy? Get DROPBOX - https://db.tt/uwjysXJF
Moderator
B
81
S
34
G
40
Posts: 3,031
Reputation: 30,422

Post » Tue Apr 18, 2017 5:00 am

The positions are relative to the canvas' top left.
So if you wanted to use a position on the layout you'd convert it with
X-canvas.left
Y-canvas.top
For every position
B
91
S
31
G
103
Posts: 5,235
Reputation: 67,756

Post » Thu Apr 20, 2017 4:37 am

Ah ok, I will test that out and see if it works. Thanks for the help @R0J0hound as always!

~Sol
Tired of crappy file hosts that are crappy? Get DROPBOX - https://db.tt/uwjysXJF
Moderator
B
81
S
34
G
40
Posts: 3,031
Reputation: 30,422


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 10 guests