How do I draw a line

0 favourites
  • 9 posts
From the Asset Store
solution for games like "fruit ninja" and drawing applications
  • 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.

  • It's a third party plugin and it draws to itself. Maybe it's not big enough?

  • 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.

  • Yeah, it's relative to the top left of the canvas.

  • 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 :/



    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.


  • SoldjahBoy

    Here's an example how to draw a filled polygon vs just a line. Hope it helps. ... .capx?dl=0

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • 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.


  • 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


    For every position

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


Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)