GUIDE

How to import and use images in the MakeCode Arcade editor

Bring an original PNG into the MakeCode Arcade editor, replace a sprite image safely, test the simulator, and diagnose common classroom import mistakes.

By Arcade Image ConverterPublished

Import the image value into an existing sprite

To use a PNG or JPG drawing in MakeCode Arcade, convert it to an Arcade image expression, then replace the image argument of a sprite in the editor's JavaScript view. Run the simulator before returning to Blocks. The important classroom skill is recognizing exactly which expression to replace while preserving the program around it.

This walkthrough starts after students have made an original drawing. It does not require downloading artwork or installing software. Use a teacher-prepared project with one visible player sprite so that the class changes one thing at a time. A successful import should leave the player in the same location with the same controls, wearing the new artwork.

Prepare a project that makes mistakes easy to spot

Open MakeCode Arcade and create a small project. Add a sprite to the start block, choose any temporary image, and make the controller move it. Run that version first. If the temporary sprite does not appear, fix the starter project before introducing an imported image. Otherwise, students may blame their picture for a problem that was already present.

Save a backup using the editor's project-saving options. Give the working copy a descriptive name such as Import Practice. Ask students to keep the original drawing separately; an imported image expression is useful game data, but it is not a replacement for an editable art file. Test the whole routine on the devices students will actually use, particularly if school policy restricts clipboard access.

Use a simple transparent PNG for the first attempt. A broad arrow, square robot, or leaf makes a better diagnostic image than a photograph. Pick one identifying feature to inspect later. A class might choose a black outline and a colored eye, then check whether both survive the journey into the simulator.

Make one small image expression

Open the image converter in a second tab. Choose the drawing, use a modest output size such as 16 by 16, and convert it. Inspect the preview before copying. This is a checkpoint: if the feature is already missing here, editing the game program will not restore it. Return to the source or choose a more suitable size first.

Original classroom robot converted to a 16 by 16 Arcade preview with image code ready to copy

The converter produces an image value. It does not export a complete game, controller setup, or movement behavior. That distinction explains the next step: you will insert the copied value into code that already knows what to do with a sprite. Microsoft's Image reference describes the row-and-column image literal format used by Arcade.

Replace only the image argument

Switch the starter project to JavaScript. Find the statement that creates the player. Its structure will resemble the short example below, although the variable name and artwork may differ. This tiny original image is intentionally simple so that the boundaries remain visible.

let player = sprites.create(
  img`
    . 2 2 .
    2 f f 2
    2 f f 2
    . 2 2 .
`,
  SpriteKind.Player
);
controller.moveSprite(player);

The image argument starts at img and includes the opening backtick, all pixel rows, and the closing backtick. It ends before the comma preceding SpriteKind.Player. Select that entire image expression, then paste the complete expression from the converter. Keep the surrounding sprites.create call, its parentheses, the comma, the sprite kind, and the variable assignment.

Have partners point to the opening and closing boundaries before anyone pastes. One partner can read the code structure aloud while the other checks the selection. This takes less time than repairing several missing commas across the room. If selecting a large expression is difficult on a tablet, the teacher can demonstrate this step and give students more time for individual practice.

Test before switching views

Use this short acceptance routine after the replacement:

  1. Confirm that the editor shows no new syntax error beside the changed statement.
  2. Restart the simulator and locate the player.
  3. Move the player with the same controls used in the starter project.
  4. Check the identifying feature at normal simulator size.
  5. Move across a contrasting background and inspect the transparent surroundings.
  6. Return to Blocks and inspect the sprite's image in its block.

Keep the first program simple enough for the editor to represent in Blocks. Arbitrary JavaScript may not turn into ordinary blocks, so returning to Blocks is a verification step rather than a promise about every program. If the class already uses advanced text code, students can continue in JavaScript after confirming the imported sprite works.

Do not change movement speed, the palette, and the image at the same time. If a student wants a bigger character, make that the next experiment after this version works. A small sequence of successful edits creates a useful recovery path: the most recent change becomes the first thing to inspect when behavior changes unexpectedly.

Diagnose the layer that failed

What students observeFirst place to inspectA useful next action
New syntax error after pastingJavaScript expression boundariesCheck both backticks and the comma after the image
New picture appears but will not moveExisting controller codeCheck that movement still refers to the created sprite
Picture looks wrong in both previewsSource and conversion sizeSimplify the drawing or preserve a larger grid
Colors change only inside the projectProject paletteCompare the project's palette with the conversion palette
White rectangle surrounds the pictureSource backgroundExport actual transparent pixels from the drawing tool
Old artwork returns laterOther image-setting codeSearch for another statement that changes this sprite's image

The table is a diagnostic order, not a substitute for looking at the project. For example, a player outside the visible screen can look like a failed image import. Restore the player's known starting position before redoing conversion. Repeatedly pasting the same valid image rarely fixes an unrelated placement error.

Make the import explainable to a partner

Ask each student to explain three objects: the source PNG, the copied text expression, and the sprite displayed by the program. A good explanation describes how one becomes the next. “I uploaded the game” is too vague; “I replaced the player's image argument and kept the movement code” identifies the actual edit and makes it reproducible.

For a short exit check, have students show the changed image in the simulator and point to its boundaries in JavaScript. Then ask what would happen if they deleted the sprite kind instead. Students do not need to memorize every API name to recognize that artwork and program structure have different jobs. The image data exercise is a follow-up for investigating the individual pixel symbols.

For students who finish early, repeat the import with a deliberately different silhouette while keeping the same program. Ask a partner to identify which properties stayed constant. Preserve the successful version before extending it into animation or multiple characters. The goal is a repeatable editing procedure students can use in their own projects.

FAQ

Can I paste the PNG file directly into the JavaScript image argument?

This workflow pastes an Arcade image expression, not a file or file path. Convert the drawing first and copy the complete expression, including both backticks.

Why does my transparent PNG still have a white box?

Check whether the background pixels are actually transparent in the source. A PNG can contain solid white pixels. A file extension alone does not remove them.

Must I replace my entire sprite creation statement?

No. Replace its image argument and retain the surrounding statement. Keeping the variable and sprite kind helps preserve the starter project's existing behavior.

Can students do this without a MakeCode account?

The converter requires no account. Use the editor's available local project workflow and your school's saving policy; keep an explicit backup rather than relying on an open tab.