How do I Draw Obstacles??

Get help using Construct 2

Post » Wed Apr 20, 2016 5:54 pm

The concept I am trying to achieve, is to allow the user to draw lines such as if you were drawing in paint and then make these lines an object which is added to a new layout where the player must navigate around this obstacle. What is the best way to create drawing lines that are smooth and effortless, and how would this drawing be transferred into the second layout?


Thanks guys
B
3
Posts: 9
Reputation: 193

Post » Wed Apr 20, 2016 7:39 pm

You can do it with a sprite that has it's origin at the left-center. It's height is the thickness and if you make it global it will survive till the next layout. The events to draw it is below. You can also create a circle sprite at the mouse to make the line look better at angles. You then can make the created objects solid or something.

global number oldx=0
global number oldy=0

on left click
--- set oldx to mouse.x
--- set oldy to mouse.y

left mouse is down
--- create sprite at (mouse.x, mouse.y)
--- sprite: set angle toward (oldx,oldy)
--- sprite: set width to distace(self.x,self.y,oldx,oldy)
B
94
S
33
G
113
Posts: 5,356
Reputation: 73,273

Post » Wed Apr 20, 2016 8:04 pm

R0J0hound wrote:You can do it with a sprite that has it's origin at the left-center. It's height is the thickness and if you make it global it will survive till the next layout. The events to draw it is below. You can also create a circle sprite at the mouse to make the line look better at angles. You then can make the created objects solid or something.

global number oldx=0
global number oldy=0

on left click
--- set oldx to mouse.x
--- set oldy to mouse.y

left mouse is down
--- create sprite at (mouse.x, mouse.y)
--- sprite: set angle toward (oldx,oldy)
--- sprite: set width to distace(self.x,self.y,oldx,oldy)


Thanks for the response R0j0. see i had something like this before and the problem I get from it is that it is not a straight line it looks like this:

Image

Like its attached to an origin
B
3
Posts: 9
Reputation: 193

Post » Wed Apr 20, 2016 8:39 pm

Oh, right. I forgot to add these two actions to the second event:

--- set oldx to mouse.x
--- set oldy to mouse.y

That should fix it.
B
94
S
33
G
113
Posts: 5,356
Reputation: 73,273

Post » Wed Apr 20, 2016 9:34 pm

R0J0hound wrote:Oh, right. I forgot to add these two actions to the second event:

--- set oldx to mouse.x
--- set oldy to mouse.y

That should fix it.



Thanks again for this.

See I am running in to the same problem i had before in that it is not a smooth, but jagged and gapped.

I have attached here what I mean:
Image

Thanks,

Harraj
B
3
Posts: 9
Reputation: 193

Post » Wed Apr 20, 2016 11:43 pm

https://
drive.google.com/open?id=0B1SSuCVV8v74ODZ4cnBMYmZuOFk

It will still jagg if the mouse is to fast.
How more dense sprite3 how smoother.

R0J0hound has made a MUCH better physics plugin with better joints.
But if i use a plugin, he aint opening my capx.

With his plugin you can make the joints pull depending on the speed of the mouse.

And another plus: framerate is not dropping at all, it drops when u scale, position & rotate towards.

You can, ofcourse, make the mouse invisible with a transparant sprite set to it.
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950

Post » Thu Apr 21, 2016 3:25 am

Make a circle Sprite whose diameter is the same as the width. Then just create one of those at the mouse while the mouse button is down.
B
94
S
33
G
113
Posts: 5,356
Reputation: 73,273

Post » Thu Apr 21, 2016 7:07 pm

R0J0hound wrote:Make a circle Sprite whose diameter is the same as the width. Then just create one of those at the mouse while the mouse button is down.


I have tried creating a circle, by basically using the paint brush and drawing a dot then resizing it to the dot size, but still the same problem. Is there another way to create an actual circle as the sprite is still a square if that makes sense??
B
3
Posts: 9
Reputation: 193

Post » Thu Apr 21, 2016 8:32 pm

B
94
S
33
G
113
Posts: 5,356
Reputation: 73,273

Post » Sun Apr 24, 2016 5:43 pm

R0J0hound wrote:https://dl.dropboxusercontent.com/u/5426011/examples33/draw_line.capx


Thank you so much for that!!! So I have now created it as an object, which is a boundary but now it is coding it to remember the position, so it remains on the next layout. Any clue on this or some sort of basic tutorial in which I can learn it?

thanks,

harraj
B
3
Posts: 9
Reputation: 193

Next

Return to How do I....?

Who is online

Users browsing this forum: No registered users and 31 guests