Array of ALL sprites?

I know “array of sprite kind”, but how can I do “array of all sprites”?

1 Like

Easy to do in JavaScript, but tough to do in blocks.

In JavaScript:

function getAllSprites() {
    const allSprites: Sprite[] = [];

    for (const key of Object.keys(game.currentScene().spritesByKind)) {
        for (const sprite of game.currentScene().spritesByKind[parseInt(key)].sprites()) {
    return allSprites;
1 Like

Thanks! I’ll stick to JavaScript.

We need a block for this :smiley:

1 Like

Good idea. That list will also include the player. Still you could check within the array if the sprite.kind is that of the player and skip doing something.

1 Like

Property 'Push' does not exist on type 'number'
Why does this happens. I just copied and pasted in, but still will not work…

Can you share your project?

I really just pasted it, I don’t know how that happened, It happens on anything though, not just that project.
EDIT: it only happens in the offline app…

I came up with this… put the arrays in an array… well this happens…(read the error thing)

Also I realised that sometimes all pictures go blank… (bug) I think when you have an error and press on the error sign! I will do an experiment about it and tell you!

@DahbixLP that code is actually creating an array of arrays of sprites. In other words, it’s an array where each of the items is another array.

1 Like

Just took @richard’s code.

I may try this…

1 Like


Wiat don’t it will break your project for some reason…

1 Like