How do I move slowly?

Get help using Construct 2

Post » Fri Feb 21, 2014 1:48 pm

I am a newbie and so this might be a very obvious question.
I want a sprite to move down 50 pixels when a certain condition is met. I have tried using "move at an angle" but it's too abrupt. I want to be able to see the movement. I have tried to use "8 movement" but didn't get anywhere. Using "8 movement", the sprite starts moving down and keeps moving. It doesn't stop after 50 px. So what do I do?
Thanks.
B
4
Posts: 28
Reputation: 280

Post » Fri Feb 21, 2014 2:16 pm

Try Set y to self.y+50*dt
B
11
S
5
G
2
Posts: 496
Reputation: 2,306

Post » Fri Feb 21, 2014 3:06 pm

Thanks for your reply. :) So quick too.
I tried your suggestion and made this capx.
But it doesn't work properly. The sprite now moves slowly and smoothly but it doesn't always stop in the right place. I am sure I am missing something but can't figure out what. :oops:
The file is below if you'd like to check it out. Thanks.
https://www.dropbox.com/s/6z397fr1x4el0dd/Movement.capx
B
4
Posts: 28
Reputation: 280

Post » Fri Feb 21, 2014 3:09 pm

The coordinate of the layout starts with 0,0 in top left corner.

All objects have an x,y value thats fits it.

So if you want an object to move Down 50 pixel, you can just add X-amount to y. To move up you subtract X-amount from Y.

So in your case to make it very simple, you can store store the current X,Y value of your object. And every 1 sec for instant, you move the object X-amount in the direction you want to. And then test:

starting value - current value > 50

If thats the case you stop the object from moving. This check you just put in the event/function that handles movement of the object. And modify it so it fits the different directions you want it to move.

Then it will slowly move in that direction.
B
44
S
11
G
2
Posts: 1,182
Reputation: 6,848

Post » Fri Feb 21, 2014 4:28 pm

nimos100 wrote:The coordinate of the layout starts with 0,0 in top left corner.

All objects have an x,y value thats fits it.

So if you want an object to move Down 50 pixel, you can just add X-amount to y. To move up you subtract X-amount from Y.

So in your case to make it very simple, you can store store the current X,Y value of your object. And every 1 sec for instant, you move the object X-amount in the direction you want to. And then test:

starting value - current value > 50

If thats the case you stop the object from moving. This check you just put in the event/function that handles movement of the object. And modify it so it fits the different directions you want it to move.

Then it will slowly move in that direction.

That will also work.OP, set your "Overlapping at Offset" condition's 100 to 25.It works,and will have a nice effect.
B
11
S
5
G
2
Posts: 496
Reputation: 2,306

Post » Fri Feb 21, 2014 4:43 pm

Would Lerp work in this case?

lerp(a, b, x) (there is also unlerp) Source

A = Starting Position (such as the X or Y of the object IE. object_name.Y)
B = Position to Reach (such as object_name.Y + 50)
X = Percentage or otherwise interpreted potentially as speed. (Ex. 0.3)


LiteTween might also work - Thread
I personally haven't used LightTween. It looks nice though and I'll likely download it to try it out.
B
73
S
10
G
6
Posts: 105
Reputation: 7,577

Post » Fri Feb 21, 2014 4:49 pm

I'm a firm believer in the use of bullet behaviour when you want things to move accurately.
Apply bullet behaviour.
Set bullet speed to 100
Set angle to 90 deg
Wait 0.5s
set bullet speed to 0.
This gives a nice smooth movement and is very, very customisable eg you can have a sprite accelerate to a certain speed then decelerate smoothly into position.
B
7
S
2
Posts: 93
Reputation: 797

Post » Fri Feb 21, 2014 4:53 pm

That will also work.OP, set your "Overlapping at Offset" condition's 100 to 25.It works,and will have a nice effect.


Changing to 25 from 100 does work beautifully. :D Could you explain how you came to that particular number and would it work if the distance of the sprites change?

And thanks to everyone who has taken an interest. :) I am trying out all the methods mentioned, even though Doc Ai's solution is easier for a newbie like me.
B
4
Posts: 28
Reputation: 280

Post » Fri Feb 21, 2014 6:18 pm

@Bertie Booster - I just tried the Bullet behavior and came up with a snag. The sprites don't always move down 100px exactly. They always end up a few of pixels up or down instead of the exact 100px. Oherwise, this seems to be a nice, easy method too. Thanks for pointing me in this direction. But for my particular problem, the positions of the pixels have to be exact. Not sure how to get there.
B
4
Posts: 28
Reputation: 280

Post » Fri Feb 21, 2014 6:25 pm

d5s wrote:
That will also work.OP, set your "Overlapping at Offset" condition's 100 to 25.It works,and will have a nice effect.


Changing to 25 from 100 does work beautifully. :D Could you explain how you came to that particular number and would it work if the distance of the sprites change?


I don't know,I am also a newbie. I don't know why 100 doesn't work :!: .
I think Bertie boosters method would be the best here.
And for your problem.Do this(A little maths)
Bulletspeed*x=distance between the two balls(In this case,100)
So 100*x=100
x=1.
So set it to 1 sec.
B
11
S
5
G
2
Posts: 496
Reputation: 2,306

Next

Return to How do I....?

Who is online

Users browsing this forum: No registered users and 26 guests