How to loop through sprites in js

Hi, how would I loop though this sprite and change the values to different colors?
thx!

Something like this?

// Get an array of all sprites that have the kind "Player"
for (const sprite of sprites.allOfKind(SpriteKind.Player)) {
    // Replace all pixels with the color 0 (transparent) with 1 (white)
    sprite.image.replace(0, 1)
}

Thanks!!!

cool - is allOfKind documented somewhere? I’m a noob - Where would I go to generally read and discover this js goodness

Our references are mostly block focused, but they’re located here:

In general I think the most useful reference in text is the toolbox that appears on the left hand side. Most of the APIs should show up there!

2 Likes