How do I move multiple sprite smoothly to Y

Get help using Construct 2

Post » Mon Dec 14, 2015 2:21 am

hi everyone,

I have a question. how to make some sprite move smoothly down by a fixed amount?
I have some objects, and wants to make them move together to the bottom (a fixed amount).
let's say 20px.

this is the image of my sprite.

Image
B
9
S
2
G
1
Posts: 28
Reputation: 671

Post » Mon Dec 14, 2015 2:51 am

You could use pin behavior to make them move together or move each of them same way with something like pick by evaluate or pick by comparsion.
Not sure how to do smoothly such a specific distance.
CustomMovement behavior might be useful if you can do some math and figure out how much and how long you need to accelerate and decelerate to move 20 pixels more smoothly than just at constant speed.
B
14
S
6
G
1
Posts: 39
Reputation: 1,644

Post » Mon Dec 14, 2015 3:35 am

Many ways to move sprites simultaneously, but you can use this,

1)Add Instance variable to sprite (InitialY)
2)On start of layout (or any triggers you want) - Set Inital Y to each sprites
3)If Sprite.Y < Sprite.InitialY (Sprite First Y) + 20 (Distance to move),
Set Sprite.Y to Self.Y + 20 * dt (it will make it move smoothly)


Image

If image not shown above use this link:
https://onedrive.live.com/redir?resid=A9AA77AEE7DA1637!2621&authkey=!AFnCeAMWbfQjbuM&v=3&ithint=photo%2cpng
Image



The Things you can create is only limited by your imagination. If you don't have the skills then use your motivation as a natural force to exceed all expectations. Chadori RebornXD
B
51
S
17
G
90
Posts: 1,108
Reputation: 59,024

Post » Mon Dec 14, 2015 3:49 am

You could do it like this. The first event moves the objects and the second corrects overshoot. Another option could be to use the MoveTo behavior.

global number toMove=20
global number speed=100

toMove>0
--- sprite: set y to self.y + speed*dt
--- subtract speed*dt from toMove

toMove<0
--- sprite: set yo to self.y +toMove
--- set toMove to 0
B
85
S
27
G
85
Posts: 5,068
Reputation: 57,870

Post » Mon Dec 14, 2015 10:37 am

wow thanks a lot @R0J0hound
it works now.

and thank you to everyone who has helped.
B
9
S
2
G
1
Posts: 28
Reputation: 671


Return to How do I....?

Who is online

Users browsing this forum: OddConfection, senna68, smlyldz and 10 guests