Discuss Scratch

skelleduck
Scratcher
15 posts

Costume Changes

https://scratch.mit.edu/projects/946999752/

I'm working on a top-down game and I'm using griffpatch's starter code.
My problem is my character moves but doesn't change its costumes to make it look like it's moving. I think it's because griffpatch's character uses only two frames of animation for each direction, whereas mine uses four. Any tips as to how to make my character move with more frames?
AlixTheMighty
Scratcher
30 posts

Costume Changes

I haven't looked at the code, but this might help:
Make a second sprite to handle the frames variable. Set that sprite up so that if frame=1: wait (however many seconds),
set frame to 0.

Then, set up your character with an if/else so that when, let's say, the right arrow key is pressed, it checks whether or not frame=0. If frame=0 then change x by (your preferred movement speed here), if rightarrowkeymovement<4 then switch costume to next costume, set frame to 1, change rightarrowkeymovement by 1. else, switch costume to moveright1. else, change x by (preferred movement speed).
skelleduck
Scratcher
15 posts

Costume Changes

AlixTheMighty wrote:

Then, set up your character with an if/else so that when, let's say, the right arrow key is pressed, it checks whether or not frame=0. If frame=0 then change x by (your preferred movement speed here), if rightarrowkeymovement<4 then switch costume to next costume, set frame to 1, change rightarrowkeymovement by 1. else, switch costume to moveright1. else, change x by (preferred movement speed).

The only problem with that is that the code to change the costumes also makes the character move. The code currently looks like this:

define key pressed (dx) (dy) costume (costume)
try move (dx) (dy)
switch map (dx) (dy)
change costume (costume)

forever
if <key [up arrow] pressed?> then
key pressed (0) (1) costume (up)
end
say [this same code repeats for every direction]
end

I'm trying to make it so that my character changes costume frames while still having it move smoothly.

Last edited by skelleduck (April 22, 2026 12:20:00)

Bearmax123
Scratcher
1 post

Costume Changes

I don't know what to say since I am new to scratch
Ff_0014
Scratcher
1 post

Costume Changes

who ive never commented her before this is cool

Powered by DjangoBB