# When sprite not moving

**URL:** <https://forum.makecode.com/t/when-sprite-not-moving/31778>\
**Category:** Help\
**Created:** [November 17, 2024, 8:42pm UTC](https://forum.makecode.com/t/when-sprite-not-moving/31778 "2024-11-17T20:42:52Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![DA\_PRO\_PLAYZ](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/da_pro_playz/32/19214_2.png) [@DA\_PRO\_PLAYZ](https://forum.makecode.com/u/DA_PRO_PLAYZ)\
**Post date:** [November 17, 2024, 8:42pm UTC](https://forum.makecode.com/t/when-sprite-not-moving/31778/1 "2024-11-17T20:42:52Z")

</div>

Hi, I was wondering if there was a way to run code when a sprite is moving, and stop running when a sprite is moving. any ideas?

---

<div class="post-metadata">

**Author:** ![RobbyZero](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/robbyzero/32/17188_2.png) [@RobbyZero](https://forum.makecode.com/u/RobbyZero)\
**Post date:** [November 18, 2024, 5:35am UTC](https://forum.makecode.com/t/when-sprite-not-moving/31778/2 "2024-11-18T05:35:17Z")

</div>

> [@DA\_PRO\_PLAYZ](#):
>
> stop running when a sprite is moving

> [@DA\_PRO\_PLAYZ](#):
>
> run code when a sprite is moving

You just explained quantum mechanics

---

<div class="post-metadata">

**Author:** ![DA\_PRO\_PLAYZ](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/da_pro_playz/32/19214_2.png) [@DA\_PRO\_PLAYZ](https://forum.makecode.com/u/DA_PRO_PLAYZ)\
**Post date:** [November 18, 2024, 7:15pm UTC](https://forum.makecode.com/t/when-sprite-not-moving/31778/3 "2024-11-18T19:15:29Z")

</div>

Oh wait. I meant stop when a sprite is not moving, and run when it IS moving. My bad. Anyway, I figured it out.

---

<div class="post-metadata">

**Author:** ![Gl125371](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/gl125371/32/29131_2.png) [@Gl125371](https://forum.makecode.com/u/Gl125371)\
**Post date:** [January 7, 2025, 6:38pm UTC](https://forum.makecode.com/t/when-sprite-not-moving/31778/4 "2025-01-07T18:38:11Z")

</div>

Can you tell me how? I also need it for a game. TY.

---

<div class="post-metadata">

**Author:** ![DA\_PRO\_PLAYZ](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/da_pro_playz/32/19214_2.png) [@DA\_PRO\_PLAYZ](https://forum.makecode.com/u/DA_PRO_PLAYZ)\
**Post date:** [January 8, 2025, 6:06pm UTC](https://forum.makecode.com/t/when-sprite-not-moving/31778/5 "2025-01-08T18:06:01Z")

</div>

Sure! I used the Sprite Utils extension, and used the Sprite speed block. Basically, if the sprite’s speed does not equal zero, it sets a variable to false. If it IS zero, it sets a variable to true. Here is the extension:

> **[GitHub - jwunderl/arcade-sprite-util: A few utility functions for sprites](https://github.com/jwunderl/arcade-sprite-util)**
>
> A few utility functions for sprites

And here is some example code:

> **[Example](https://arcade.makecode.com/S93800-33009-86576-29843)**
>
> Made with ❤️ in Microsoft MakeCode Arcade.

---

<div class="post-metadata">

**Author:** ![Gl125371](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/gl125371/32/29131_2.png) [@Gl125371](https://forum.makecode.com/u/Gl125371)\
**Post date:** [January 8, 2025, 6:45pm UTC](https://forum.makecode.com/t/when-sprite-not-moving/31778/6 "2025-01-08T18:45:45Z")

</div>

Thank you!
