Draw a path after a physics object

Get help using Construct 2

Post » Mon Nov 11, 2013 5:57 pm

Hello.
I got a question I was researching for some time today. Is there any "right" way to draw a line that represents a physics object path. For example a sphere is falling down is some kind of labyrinth and I need to draw a path that a sphere took. Currently I'm spawning a dot at the sphere position every "0.n" seconds but this is not working as needed because the sphere can change it's speed and the dots representing the path will be more dense when it's slow. The perfect way would be to draw a path every "n" pixels traveled, but I can't find a way to get the position of the last spawned point to calculate the distance.
Any ideas?BORODA2013-11-11 18:04:55
B
8
S
3
G
2
Posts: 4
Reputation: 1,599

Post » Mon Nov 11, 2013 6:21 pm

Maybe the example I linked to inThis topic could be of use..
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Mon Nov 11, 2013 6:52 pm

Easiest thing would be using the canvas plugin with "line to" and draw path.

If you wanna draw every x traveled use something like (posx, posy = global vars, set them to sprite.x and sprite.y at the start of the layout):

distance(sprite.x,sprite.y,posx,posy) greater of equal 10: call function "draw line"
set posx = sprite.x
set posy = sprite.y

and function draw line contains the drawing on the canvas.

This would prevent you from having to deal with a big number of objects.
If you playing area is very big ofc it is better to just spawn those points and then delete them when offscreen or use multiple canvases.
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: 787
Reputation: 3,786

Post » Mon Nov 11, 2013 8:07 pm

Thanks for the fast reply
I actually combined both of your suggestions to get the result I was looking for.
Thanks again!
B
8
S
3
G
2
Posts: 4
Reputation: 1,599


Return to How do I....?

Who is online

Users browsing this forum: David181, yiuyiu6666 and 29 guests