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

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

2 Likes

In Sprites:
image
Section Lifecycle:
image
There is the on destroyed sprite of kind {Kind}.

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

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.


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. I try to update it with new extensions ASAP but it’s often behind because I’m busy. :confused:

3 Likes

here is some code

Thanks. I will try that extension.

2 Likes

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’. :+1:

2 Likes