i was wondering, can you add lives to enemy’s in the block coding?
Unfortunately, this is pretty difficult to do in blocks. The hack I usually use is the z-index; you can set the z-index of the sprite to the max number of lives (i.e. 10) and then decrement it whenever the enemy is hit. Then when the z is 0, you destroy the sprite.
If you do that you’ll probably need to set the z-index of the player (and other sprites) to something higher than 10. That way they’ll still be displayed above the sprite.
Here is information on the z-index: https://arcade.makecode.com/reference/sprites/sprite/z
Built some helper blocks for my students, may help.
That’s a great extension! Just so you know, in the block definition you can set it to have a variable dropdown for the sprite variable with with
//% blockId="set_sprite_life" block="set %sprite=variables_get(mySprite) life to %lives"
will show up as
also, if you want to make that a full extension github extension in the future, might be useful to know that each sprite has a
.data field that you can store data in; e.g.
sprite.data["SPRITE_LIFE_EXTENSION_KEY"] = lives;
Wow! With your help the usability finally catches up with the built-in blocks. Thank you!
A quick modification to an extension.
Don’t forget to create a release for your extension!
But how do I transfer the extension to my project?
@codebott578 in the toolbox there is an “+ extension” button in the advanced section.
To add any GitHub extension:
- Press “+ extension”
- Get the GitHub the URL for the extension,
- Paste it into the search box that appears, and hit enter
- You should see a card for the extension with the name displayed. Click it and the blocks should show up in the toolbox
Make sure you back up your game before you add any extensions!
Can you record how to do it. That will give me a better idea of how to do it
Here you go! I should mention that this is not a Microsoft extension and I haven’t tested it out yet.
Thanks! That explains it.
@reyhanPanci256 are you connected to the internet?