# Any way to attach image AND string to the image in an array?

**URL:** <https://forum.makecode.com/t/any-way-to-attach-image-and-string-to-the-image-in-an-array/45798>\
**Category:** Help\
**Tags:** game, make\
**Created:** [September 8, 2026, 3:25pm UTC](https://forum.makecode.com/t/any-way-to-attach-image-and-string-to-the-image-in-an-array/45798 "2026-09-08T15:25:25Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![RizeUpDev](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/rizeupdev/32/35291_2.png) [@RizeUpDev](https://forum.makecode.com/u/RizeUpDev)\
**Post date:** [September 8, 2026, 3:25pm UTC](https://forum.makecode.com/t/any-way-to-attach-image-and-string-to-the-image-in-an-array/45798/1 "2026-09-08T15:25:25Z")

</div>

Is there a way to attach an image and a string to it in an array? This would help a lot for games that have lots of bad guys!

---

<div class="post-metadata">

**Author:** ![Bilangus](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/bilangus/32/33219_2.png) [@Bilangus](https://forum.makecode.com/u/Bilangus)\
**Post date:** [September 8, 2026, 8:42pm UTC](https://forum.makecode.com/t/any-way-to-attach-image-and-string-to-the-image-in-an-array/45798/2 "2026-09-08T20:42:29Z")

</div>

I assume you’re doing an array that has both the enemy’s sprite and name? I haven’t managed to make that work in any way but you could just do separate arrays

---

<div class="post-metadata">

**Author:** ![VoxelMaster64](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/voxelmaster64/32/32075_2.png) [@VoxelMaster64](https://forum.makecode.com/u/VoxelMaster64)\
**Post date:** [September 9, 2026, 2:29am UTC](https://forum.makecode.com/t/any-way-to-attach-image-and-string-to-the-image-in-an-array/45798/3 "2026-09-09T02:29:00Z")

</div>

in JS you can do something like:

```javascript
const enemies = [
    [assets.image`enemy1`, "enemy 1"],
    [assets.image`enemy2`, "enemy 2"],
    [assets.image`enemy3`, "enemy 3"]
]
const enemySprites: Sprite[] = []

for (const enemy of enemies) {
    const enemySprite = sprites.create(enemy[0] as Image, SpriteKind.Enemy)
    enemySprite.data = enemies[1] as string
    enemySprites.push(enemySprite)
}

```

or:

```javascript
interface rawEnemy = { image: Image, name: string }
const enemies = [
    { image: assets.image`enemy1`, name: "enemy 1" },
    { image: assets.image`enemy2`, name: "enemy 2" },
    { image: assets.image`enemy3`, name: "enemy 3" }
]
const enemySprites: Sprite[] = []

for (const enemy of enemies) {
    const enemySprite = sprites.create(enemy.image, SpriteKind.Enemy)
    enemySprite.data = enemies.name
    enemySprites.push(enemySprite)
}

```

in js, I don’t think you can do much unless somebody makes a to type function (currently trying)

---

<div class="post-metadata">

**Author:** ![CodaKnight](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/codaknight/32/33491_2.png) [@CodaKnight](https://forum.makecode.com/u/CodaKnight)\
**Post date:** [September 9, 2026, 2:37am UTC](https://forum.makecode.com/t/any-way-to-attach-image-and-string-to-the-image-in-an-array/45798/4 "2026-09-09T02:37:49Z")

</div>

If you’re using blocks, you could use @richard 's better-sprite-data extension:

> **[GitHub - riknoll/arcade-improved-sprite-data: A MakeCode Arcade extension for storing data on...](https://github.com/riknoll/arcade-improved-sprite-data)**
>
> A MakeCode Arcade extension for storing data on sprites

I haven’t tested it out for objects, but it does say on the awesome arcade that it “expands upon the built-in sprite data extension by providing more types including tilemap locations, functions, and the array versions of the base types that can be stored not only on sprites but also the tilemap locations on the current tilemap and an “object”, replacing the arcade-block-objects extension.”

If you’re using like JS/TS you can just use an interface like this:

```typescript
interface EnemyData {
    name: string
    image: Image
    health: number
    damage: number
    speed: number
}
//----
let enemyTypes: EnemyData[] = [
    {
        name: "Goblin",
        image: img`...`,
        health: 20,
        damage: 5,
        speed: 80
    },
    {
        name: "Slime",
        image: img`...`,
        health: 10,
        damage: 2,
        speed: 40
    },
    {
        name: "Knight",
        image: img`...`,
        health: 100,
        damage: 20,
        speed: 30
    }
]

```

---

<div class="post-metadata">

**Author:** ![TheEarth](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/theearth/32/34579_2.png) [@TheEarth](https://forum.makecode.com/u/TheEarth)\
**Post date:** [September 9, 2026, 5:21pm UTC](https://forum.makecode.com/t/any-way-to-attach-image-and-string-to-the-image-in-an-array/45798/5 "2026-09-09T17:21:30Z")

</div>

you know js right because u made an extension so use classes

---

<div class="post-metadata">

**Author:** ![RizeUpDev](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/rizeupdev/32/35291_2.png) [@RizeUpDev](https://forum.makecode.com/u/RizeUpDev)\
**Post date:** [September 9, 2026, 5:39pm UTC](https://forum.makecode.com/t/any-way-to-attach-image-and-string-to-the-image-in-an-array/45798/6 "2026-09-09T17:39:40Z")

</div>

Hmm.. I’ve never seen the improved sprite data extension. Can’t wait to try it out!
