Movement To Path By Pixels (aka am I dumb?)

Get help using Construct 2

Post » Mon Feb 25, 2013 7:56 am

So far - I haven't had any of my questions answered so I'm starting to wonder if I'm asking dumb questions...

Anyway here is another one...

I've been searching the forums a lot - and I see a lot of grid based movement and board movement etc - but I think I'm trying to do something really simple and I'm just dumb...

So here is what I'm trying to do:

Have a map - I set the sprite to the target - i move the sprite x amount of pixel each turn to the position - there is no objects or anything that will block it's path.


And here is what I came up with:

VAR speed = 32 (pixels)
SPRITE.X = 10
SPRITE.Y = 10
VAR x 300
VAR y 300
VAR distanceToMove = 0

Every Tick
distance != speed
Round(Sprite.X) != Round(x)
Round(Sprite.y) != Round(y)
---------Action = Sprite set angle toward (x,y)
                  Sprite move forward 1 pixels
                  Sprite Add 1 to distToMove

This makes it move as I wanted - but this sits in the main event and I wanted it as a function which I could pass in X,Y Speed etc - but I couldn't get it to move to the location pixel by pixel turn by turn...

How dumb am I?
Thanks!


B
13
S
1
Posts: 17
Reputation: 946

Post » Tue Feb 26, 2013 5:39 am

Um... Please help?
B
13
S
1
Posts: 17
Reputation: 946

Post » Tue Feb 26, 2013 6:01 am

Your best bet is to post a capx file. Pseudo code isn't your friend here.
ImageImageImage
B
67
S
19
G
122
Posts: 3,200
Reputation: 73,387

Post » Tue Feb 26, 2013 6:26 am

Ah!
Okay let's see if this work!https://dl.dropbox.com/u/11212446/test.capx
B
13
S
1
Posts: 17
Reputation: 946

Post » Tue Feb 26, 2013 6:48 am

test_fnc

This does what you have but with two functions. Doesn't need to be two, just showing variations of calling functions.
ImageImageImage
B
67
S
19
G
122
Posts: 3,200
Reputation: 73,387

Post » Tue Feb 26, 2013 6:51 am

Thanks

The link appears to be broken though :(
B
13
S
1
Posts: 17
Reputation: 946

Post » Tue Feb 26, 2013 6:55 am

http://bht.hostingsiteforfree.com/samples/test_fnc.capx
ImageImageImage
B
67
S
19
G
122
Posts: 3,200
Reputation: 73,387

Post » Tue Feb 26, 2013 7:03 am

Appears you're using 120 i'm using the purchased Steam Version - Thanks for your time I'll see if I can install 2 versions to check it out!
BRB!
B
13
S
1
Posts: 17
Reputation: 946

Post » Tue Feb 26, 2013 7:17 am

Got it open!
Thank you so much for taking the time to do this - I'm not understanding how it is working - I'll keep playing with it until i understand what it's doing. Thanks again for the help!
B
13
S
1
Posts: 17
Reputation: 946


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 17 guests