how do i bring a sprite to a stop

Get help using Construct 2

Post » Fri Feb 17, 2012 1:38 am


i have three instances of a sprite,

i'm trying to get them to move to a random position (RandomX, RandomY) at a bullet speed S every 3 seconds.

what's happening is that every 3 seconds the sprites definitely move in a random direction, but they go past that random destination, the distance function doesn't seem to have an effect.

i tried putting the distance function as a sub-event to the for each... event, but no joy; tried using lerp, but i don't think i understood it well enough to make it work.

so, any help would be appreciated

http://dl.dropbox.com/u/62693846/sample.capx
B
15
S
5
Posts: 22
Reputation: 1,496

Post » Fri Feb 17, 2012 3:19 am

New to Construct ? Where to start

Image Image

Image Image

Please attach a capx to any help request or bug report !
Moderator
B
289
S
112
G
94
Posts: 7,333
Reputation: 69,287

Post » Fri Feb 17, 2012 9:43 pm


thanks, that works pretty well

so it seems, as far as sprite movement is concerned; one can't use just DestX as the destination coordinate, instead you have to use Self.DestX
B
15
S
5
Posts: 22
Reputation: 1,496

Post » Sat Feb 18, 2012 8:17 am

DestX/DestY is an instance variable I set to the object.
Self is just a keyword to prevent having to type in the object's name.

As each object has a different destination, you need to put it as instance variable (one pair of variable for each object with different values), not global variable (only one pair for all the objects).
New to Construct ? Where to start

Image Image

Image Image

Please attach a capx to any help request or bug report !
Moderator
B
289
S
112
G
94
Posts: 7,333
Reputation: 69,287


Return to How do I....?

Who is online

Users browsing this forum: brunopalermo, MikaelS, nahima and 18 guests