# Sprite destruction as an event and checking status of a sprite (destroyed vs active)

**URL:** <https://forum.makecode.com/t/sprite-destruction-as-an-event-and-checking-status-of-a-sprite-destroyed-vs-active/5875>\
**Category:** Help\
**Created:** [January 30, 2021, 1:39am UTC](https://forum.makecode.com/t/sprite-destruction-as-an-event-and-checking-status-of-a-sprite-destroyed-vs-active/5875 "2021-01-30T01:39:11Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![PaulT123](https://avatars.discourse-cdn.com/v4/letter/p/e68b1a/32.png) [@PaulT123](https://forum.makecode.com/u/PaulT123)\
**Post date:** [January 30, 2021, 1:39am UTC](https://forum.makecode.com/t/sprite-destruction-as-an-event-and-checking-status-of-a-sprite-destroyed-vs-active/5875/1 "2021-01-30T01:39:11Z")

</div>

Hi,

I am a rookie with makecode so if this question has been asked and answered I apologize. I have 2 questions;

1. I’m looking for a way to have an action when a sprite is destroyed. For example, if a specific sprite is destroyed I want to change a variable to a certain value. I haven’t seen any blocks that would allow me to do that. Thoughts?

2. I’m looking for a way to check the status of a sprite (whether it is destroyed or active) but can’t seem to find anyway to do that. Thoughts?

Thanks for any help you can give,

Paul

---

<div class="post-metadata">

**Author:** ![UnsignedArduino](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/unsignedarduino/32/592_2.png) [@UnsignedArduino](https://forum.makecode.com/u/UnsignedArduino)\
**Post date:** [January 30, 2021, 2:15am UTC](https://forum.makecode.com/t/sprite-destruction-as-an-event-and-checking-status-of-a-sprite-destroyed-vs-active/5875/2 "2021-01-30T02:15:28Z")

</div>

> [@PaulT123](#):
>
> I’m looking for a way to have an action when a sprite is destroyed. For example, if a specific sprite is destroyed I want to change a variable to a certain value. I haven’t seen any blocks that would allow me to do that. Thoughts?

In `Sprites`:  
 ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/b/b4dfd98148614de0c945d885a74ccb06c258f752.png)  
Section `Lifecycle`:  
 ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/9/9b874d1ffc645517927c75d82aadf995ecd7ece8.png)  
There is the `on destroyed sprite of kind {Kind}`.

> [@PaulT123](#):
>
> I’m looking for a way to check the status of a sprite (whether it is destroyed or active) but can’t seem to find anyway to do that. Thoughts?

There is an extension by @jwunderl called `arcade-sprite-util`, which you can import with this URL:

> **[GitHub - jwunderl/arcade-sprite-util: A few utility functions for sprites](https://github.com/jwunderl/arcade-sprite-util)**
>
> A few utility functions for sprites. Contribute to jwunderl/arcade-sprite-util development by creating an account on GitHub.

As the description says, it has a few utility functions for sprites, and is especially helpful if you don’t want to deal with trigonometry as it abstracts some of that too.

 ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/2/2af4146b68f3cb978f0b646a84cb1ee2a37680b1.png)  
The first block in the `Sprite Utils` category returns a boolean depending on whether a sprite is destroyed or not.

* * *

**SHAMELESS SELF PROMOTION**  
I have made a GitHub repo which lists a bunch of extensions like Joey’s [here](https://github.com/UnsignedArduino/Awesome-Arcade-Extensions). I try to update it with new extensions ASAP but it’s often behind because I’m busy. 😕

---

<div class="post-metadata">

**Author:** ![ChickenBoy](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/chickenboy/32/717_2.png) [@ChickenBoy](https://forum.makecode.com/u/ChickenBoy)\
**Post date:** [January 30, 2021, 5:25am UTC](https://forum.makecode.com/t/sprite-destruction-as-an-event-and-checking-status-of-a-sprite-destroyed-vs-active/5875/3 "2021-01-30T05:25:56Z")

</div>

here is some code

 ![Microsoft MakeCode Arcade - Google Chrome 2021-01-29 9_13_35 PM](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/b/b9296dfc03c08fa9cb7104f88b73931584b5af90.png)

---

<div class="post-metadata">

**Author:** ![PaulT123](https://avatars.discourse-cdn.com/v4/letter/p/e68b1a/32.png) [@PaulT123](https://forum.makecode.com/u/PaulT123)\
**Post date:** [January 30, 2021, 5:26am UTC](https://forum.makecode.com/t/sprite-destruction-as-an-event-and-checking-status-of-a-sprite-destroyed-vs-active/5875/4 "2021-01-30T05:26:21Z")

</div>

Thanks. I will try that extension.

---

<div class="post-metadata">

**Author:** ![cosmoscowboy](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/cosmoscowboy/32/1718_2.png) [@cosmoscowboy](https://forum.makecode.com/u/cosmoscowboy)\
**Post date:** [January 30, 2021, 5:43pm UTC](https://forum.makecode.com/t/sprite-destruction-as-an-event-and-checking-status-of-a-sprite-destroyed-vs-active/5875/5 "2021-01-30T17:43:03Z")

</div>

ALWAYS reference the two sprite variables in the overlap event, i.e. ‘sprite’ & ‘otherSprite’. If you have multiple enemies, mySprite would only point to the last enemy added to the game. So you should destroy ‘otherSprite’. 👍
