Posted on

Scratch Coding – Dress Up

This week we are building a game that will help our character wear some clothes.

The idea is that we will click on a piece of clothing and have it move to the correct spot on our character. If we select two types of the same piece of clothing we will have to move one back in place, for example if I select the pants and then the shorts, the pants move back to the wardrobe.

Let’s start with using the Dani sprite, this has costumes for both Male and Female characters.

Then let’s add a number of clothing sprites:

Starting Out

When the green flag is pressed, let’s have the player move to a known location on the screen and say ‘What should I wear?’


Each piece of clothing must also start in a spot just a little to the right of the character. We can click on each sprite and move it to the location we want and then look at the X, Y position on the go to block and use that as a starting point.

We also call the show block – we will be hiding some of our clothes later, so this helps us make sure they can be seen.

When the sprite is clicked on, we want to move the clothing to the character:

We can use the glide block to animate our clothes to a certain spot.

Test the game.

What we find is that we can pile on more clothes and make our character look crazy. We really need to remove our clothes if another one is already in place.
We need to add to the code that runs when our sprite is clicked:

For a scarf:

The scarf will always be looking for the other scarf and if it finds it, it will move the scarf back in place.

If I had three shirts that we could try on, my code might look like:

Camera Mode

We can add a camera sprite, when it is clicked we will change the backdrop and make sure the other clothes are hidden, this gives us a chance to take a nice little photo.

On each of our clothing sprites we need to make sure that we hide the clothes:

We only want to hide if we are not touching the character.