How do I draw points at regular distance

Get help using Construct 2

Post » Thu Oct 13, 2016 9:42 pm

Hi there,
I've been making a gesture path drawing for a sprite to follow. Everything works fine except for the path drawn with the mouse. I'd like to have dots to be spawn at a regular distance from one another.
Anyone has an idea on how to do that ?
Here the .capx I'm working on : https://www.dropbox.com/s/7befiup6yrfwx ... .capx?dl=0
B
33
S
14
G
5
Posts: 232
Reputation: 5,557

Post » Fri Oct 14, 2016 2:49 am

For Loop
base + increment*loopindex
ImageImageImage
B
39
S
22
G
11
Posts: 492
Reputation: 9,925

Post » Fri Oct 14, 2016 6:00 am

Thanks @badmoodtaylor
but how do I implement that ?
B
33
S
14
G
5
Posts: 232
Reputation: 5,557

Post » Fri Oct 14, 2016 10:27 am

B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950

Post » Fri Oct 14, 2016 11:24 am

Laurent wrote:Thanks @badmoodtaylor
but how do I implement that ?


Sorry, I didn't look at your capx so not sure what you are doing exactly, but here's an example to explain what I mean and you can apply it to your situation.

Let's say you want to create 10 sprites starting at coordinates 100, 100 and every 25px moving straight right (increasing X):
ON whatever triggers
-For startindex=0 endindex=9
--create sprite at location x = 100 + 25*loopindex; y = 100

This will create 10 sprites at x coordinates 100, 125, 150, 175, 200...
ImageImageImage
B
39
S
22
G
11
Posts: 492
Reputation: 9,925

Post » Fri Oct 14, 2016 8:35 pm

Well, I managed to make it work on a computer but it despertly doesn't work on a touch device.
Here is the capx : https://www.dropbox.com/s/kabhgy1qz9rtg ... .capx?dl=0
B
33
S
14
G
5
Posts: 232
Reputation: 5,557

Post » Fri Oct 14, 2016 8:41 pm

badmoodtaylor wrote:
Laurent wrote:Thanks @badmoodtaylor
but how do I implement that ?


Sorry, I didn't look at your capx so not sure what you are doing exactly, but here's an example to explain what I mean and you can apply it to your situation.

Let's say you want to create 10 sprites starting at coordinates 100, 100 and every 25px moving straight right (increasing X):
ON whatever triggers
-For startindex=0 endindex=9
--create sprite at location x = 100 + 25*loopindex; y = 100

This will create 10 sprites at x coordinates 100, 125, 150, 175, 200...


Hi Badmood,
thanks for the advice. Actually I'm trying to draw a path with the mouse spawning dots on a regular distance. Then, a sprite follows the path
B
33
S
14
G
5
Posts: 232
Reputation: 5,557

Post » Fri Oct 14, 2016 8:53 pm

Laurent wrote:Hi Badmood,
thanks for the advice. Actually I'm trying to draw a path with the mouse spawning dots on a regular distance. Then, a sprite follows the path


Ah, I didn't catch that. Maybe:

Pick most recent waypoint (or player if no waypoints)
-Compare two values If distance(mouse.x, mouse.y, waypoint.x, waypoint.y) > [distance you would like them]
--spawn waypoint at mouse.x mouse.y

Sorry, I can't look at your capx right now so not sure if that is the behavior you are looking for. If it is, to pick the most recent waypoint you may need an instance variable or boolean—although I think there is an expression to pick the last created instance but I'm not familiar.
ImageImageImage
B
39
S
22
G
11
Posts: 492
Reputation: 9,925

Post » Fri Oct 14, 2016 9:52 pm

Thanks @Badmood
But I'm afraid I'm not good enough with Construct to really understand your advices. If ever you sometime have the chance to look at the capx, it might tell you more about my needs.
B
33
S
14
G
5
Posts: 232
Reputation: 5,557

Post » Sat Oct 15, 2016 3:19 am

Give this a try:
https://www.dropbox.com/s/9uwvydzy1dsf0 ... .capx?dl=0

Not sure it is the best way but worked with what you had started. I was impressed with some of what you had—haven't done anything like that before
ImageImageImage
B
39
S
22
G
11
Posts: 492
Reputation: 9,925

Next

Return to How do I....?

Who is online

Users browsing this forum: jorgmaquoi, marc254, tarek2, Yahoo [Bot] and 28 guests