How do I draw lines ?

Get help using Construct 2

Post » Sun Nov 17, 2013 7:44 am

I am starting to work at a connect-the-dots game. I figured the technical part, but I don't know how to draw lines (like Pencil Tool from Paint)

The technical part goes something like this:
There are points A and B and the event starts when the player touches point A. Then, every X seconds (0.5s ~ 0.7s) the position of the touched area is memorized in an array. When the user touches point B, an invisible object (line) is created starting from point A and finished to point B. Then an event checks and validates the line drawn by user if the object overlaps all the points recorded in the array.

So the question that remains is how to draw lines ? (I need a better method then to create small dots (objects) every frame)

Also feel free to correct me if the logic behind the technical part is wrong or if it can be optimized even better
B
49
S
15
G
6
Posts: 535
Reputation: 7,197

Post » Sun Nov 17, 2013 8:07 am

Just Create a rectangle sprite 1 pixel high(or your choice of width), Move the origin point to far left. When you want to draw a line, create the sprite in x,y of starting point, set angle to start point x, start point y, end point x, end point y, then Set width to start point x, start point y, end point x, end point y.

I am not sure
about the Order though.
B
18
S
4
G
1
Posts: 332
Reputation: 3,149

Post » Sun Nov 17, 2013 1:41 pm

You could also use the canvas plugin. Makes drawing stuff easier.
Visual Novel 'Engine' in 100 Events
if you ever have to choose between buying Construct 2 on scirra.com or on Steam, read this: Review
B
22
S
9
G
1
Posts: 788
Reputation: 3,788

Post » Sun Nov 17, 2013 2:46 pm

It's not exactly what you looking for. But i created a line drawing experiment while ago. It can give you some ideas.

http://static1.scirra.net/arcade/games/6037/simple-free-drawing.capx
B
21
S
8
G
6
Posts: 177
Reputation: 8,134

Post » Sun Nov 17, 2013 6:02 pm

@Windwalker
@mrcgkh

Thanks, but I know how to make a Straight line ... I need to know how to make a Drawn line


@mindfaQ

Do you mean this one ?
http://www.scirra.com/forum/plugin-canvas_topic46006.html
Does it work without WebGL ?
B
49
S
15
G
6
Posts: 535
Reputation: 7,197

Post » Sun Nov 17, 2013 6:09 pm

Yeah, the only way to do this really well is with the canvas plugin, or the paster plugin. Canvas if you don't use webGL, Paster if you want to use webGL.
B
92
S
31
G
24
Posts: 3,191
Reputation: 32,699

Post » Sun Nov 17, 2013 6:41 pm

Yeah works without WebGL, try code like this:


edit: you can probably also add the condition for lastx and lasty to be different from the mouse positions to save some resources.mindfaQ2013-11-17 18:42:39
Visual Novel 'Engine' in 100 Events
if you ever have to choose between buying Construct 2 on scirra.com or on Steam, read this: Review
B
22
S
9
G
1
Posts: 788
Reputation: 3,788

Post » Sun Nov 17, 2013 6:48 pm

@mindfaQ
@sqiddster

Thank you
At the moment I want to make simple games that run well on mobile browsers so is great that Canvas Plugin works without WebGL
B
49
S
15
G
6
Posts: 535
Reputation: 7,197

Post » Thu Nov 28, 2013 10:31 pm

Switching from Canvas to Paster since Canvas has lower FPS when WebGL is enabled
B
49
S
15
G
6
Posts: 535
Reputation: 7,197

Post » Wed Jan 18, 2017 8:58 am

I had a little fiddle and managed to make this, hold your mouse to draw.
https://drive.google.com/open?id=0B8Hlh ... WdyNFZPN0U
yes.

__

|:D|

Gamjolt account:http://gamejolt.com/profile/masgame/409321/
B
35
S
14
G
3
Posts: 38
Reputation: 4,832

Next

Return to How do I....?

Who is online

Users browsing this forum: No registered users and 29 guests