Sprite Properties in MakeCode Arcade
You may have already read my post on setting up sprites in MakeCode Arcade, but have you explored all of the properties that come along with Arcade sprites?
A sprite property is a feature or value that’s stored inside the sprite itself. These properties can be accessed or changed using code.
Arcade presents you with a long list of default properties that are associated with sprites. Things like x or y location, velocity, scale, and lifespan can all be managed using built-in setters and getters.
Arcade also has an extension that will allow you to create your own custom properties on your sprites!
The arcade-sprite-data extension gives you the ability to add and manage your own data categories for sprites.
Create a data property by “setting” the data label on the sprite, and give it a value. Then, you can manage that value the same way you would manage a score, life, or flag.
This extension is also a great way to add HP or XP to players and enemies since Arcade has no explicit hit point counter built-in.
Give this extension a try. Is there anything you’re able to do now that you weren’t before? If so, let me know by leaving a comment below.