# Moving platforms, how to make a sprite stay on another sprite

**URL:** https://forum.makecode.com/t/moving-platforms-how-to-make-a-sprite-stay-on-another-sprite/13934
**Category:** Help
**Created:** [June 3, 2022, 4:52pm UTC](https://forum.makecode.com/t/moving-platforms-how-to-make-a-sprite-stay-on-another-sprite/13934 "2022-06-03T16:52:36Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Starfox2k](https://avatars.discourse-cdn.com/v4/letter/s/4bbf92/32.png) [@Starfox2k](https://forum.makecode.com/u/Starfox2k)
#### Post date: [June 3, 2022, 4:52pm UTC](https://forum.makecode.com/t/moving-platforms-how-to-make-a-sprite-stay-on-another-sprite/13934/1 "2022-06-03T16:52:36Z")

</div>

So I’m making a game with moving platforms. I figured out how to  
make a sprite sit on another. But it only works on the first moving platform  
and not the rest. Help would be greatly appreciated. Thanks.

> **[3 Level Platformer](https://arcade.makecode.com/84550-59928-96542-77150)**
>
> Made with ❤️ in Microsoft MakeCode Arcade.

---

<div class="post-metadata">

### Author: ![felixtsu](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/felixtsu/32/12024_2.png) [@felixtsu](https://forum.makecode.com/u/felixtsu)
#### Post date: [June 6, 2022, 5:10pm UTC](https://forum.makecode.com/t/moving-platforms-how-to-make-a-sprite-stay-on-another-sprite/13934/2 "2022-06-06T17:10:19Z")

</div>

Only the last generated platform is checked, should check against all platforms using for-each loop

> **[3 Level Platformer](https://arcade.makecode.com/40673-81537-81069-98852)**
>
> 用❤️创造，Microsoft MakeCode Arcade出品。

btw, the sprite should be above the platform instead of overlapping (consider when player jumping under a platform), thus additional condition is needed, say player.y \< platform.y ( more precise: (platform.y - player.y) - (player.height + platform.height) / 2 \< epsilon )

---

<div class="post-metadata">

### Author: ![145145](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/145145/32/17436_2.png) [@145145](https://forum.makecode.com/u/145145)
#### Post date: [May 30, 2023, 4:43pm UTC](https://forum.makecode.com/t/moving-platforms-how-to-make-a-sprite-stay-on-another-sprite/13934/3 "2023-05-30T16:43:19Z")

</div>

here is a game with moving platforms left and right arrows to move a to freeze time

---

<div class="post-metadata">

### Author: ![145145](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/145145/32/17436_2.png) [@145145](https://forum.makecode.com/u/145145)
#### Post date: [May 30, 2023, 10:07pm UTC](https://forum.makecode.com/t/moving-platforms-how-to-make-a-sprite-stay-on-another-sprite/13934/4 "2023-05-30T22:07:51Z")

</div>

> **[time](https://arcade.makecode.com/32667-02825-01539-79640)**
>
> Made with ❤️ in Microsoft MakeCode Arcade.
