Discuss Scratch

ramenosu
Scratcher
55 posts

Does anyone know how to make a sprite crouch?

I've been trying to figure it out, but can't seem to get it working.
Here's the project: https://scratch.mit.edu/projects/351615123/
MathPuppy314
Scratcher
500+ posts

Does anyone know how to make a sprite crouch?

if <key [s v] pressed?> then
switch costume to [crouch v]
if <key [d v] pressed?> then
walk (90) (2)
else
if <key [a v] pressed?> then
walk (-90) (-2)
else
set [frame v] to [0]
end
end
end

Last edited by MathPuppy314 (Dec. 12, 2019 02:18:35)

ramenosu
Scratcher
55 posts

Does anyone know how to make a sprite crouch?

Thanks! I'll try it out.
ramenosu
Scratcher
55 posts

Does anyone know how to make a sprite crouch?

It doesn't seem to work. It keeps flinching when I hold it.
MathPuppy314
Scratcher
500+ posts

Does anyone know how to make a sprite crouch?

IDK then…
JplaysStuff
Scratcher
100+ posts

Does anyone know how to make a sprite crouch?

You can just make a script that has Toad change his sprite to a crouching sprite when a button is pressed, and maybe reduce his horizontal speed so he can slide + crouch. I don't know how your collision system works, so just tweak with a bit and see what happens.
semmiesem9
Scratcher
100+ posts

Does anyone know how to make a sprite crouch?

I would add a -1 frame for crouching, and place it before or after the A or D key inputs depending on whether you want it to prioritize crouching on moving.

if <key [s v] pressed> then //place this with the other keys
set [frame v] to (-1)
else
... //either the entire A/D/else inputs or the "set frame to 0"
end

Then change to the crouching sprite in the Set Costume block.

if <(frame) = [0]> then
switch costume to [idle v]
else
if <(frame) = [-1]> then
switch costume to [crouch v]
else
switch costume to ([floor v] of ((1) + ((frame) mod (8)))
ramenosu
Scratcher
55 posts

Does anyone know how to make a sprite crouch?

Thanks! I'll try these both.
ramenosu
Scratcher
55 posts

Does anyone know how to make a sprite crouch?

Thanks! I'll try these both.
ramenosu
Scratcher
55 posts

Does anyone know how to make a sprite crouch?

JplaysStuff wrote:

You can just make a script that has Toad change his sprite to a crouching sprite when a button is pressed, and maybe reduce his horizontal speed so he can slide + crouch. I don't know how your collision system works, so just tweak with a bit and see what happens.

I don't understand what you mean by that since I don't really use scratch a lot and I'm new.
ramenosu
Scratcher
55 posts

Does anyone know how to make a sprite crouch?

semmiesem9 wrote:

I would add a -1 frame for crouching, and place it before or after the A or D key inputs depending on whether you want it to prioritize crouching on moving.

if <key [s v] pressed> then //place this with the other keys
set [frame v] to (-1)
else
... //either the entire A/D/else inputs or the "set frame to 0"
end

Then change to the crouching sprite in the Set Costume block.

if <(frame) = [0]> then
switch costume to [idle v]
else
if <(frame) = [-1]> then
switch costume to [crouch v]
else
switch costume to ([floor v] of ((1) + ((frame) mod (8)))[/quote]


Is it okay if you remix the game so I see what you mean? I'm sorry if I'm bugging you.
semmiesem9
Scratcher
100+ posts

Does anyone know how to make a sprite crouch?

ramenosu wrote:

semmiesem9 wrote:

I would add a -1 frame for crouching, and place it before or after the A or D key inputs depending on whether you want it to prioritize crouching on moving.

if <key [s v] pressed> then //place this with the other keys
set [frame v] to (-1)
else
... //either the entire A/D/else inputs or the "set frame to 0"
end

Then change to the crouching sprite in the Set Costume block.

if <(frame) = [0]> then
switch costume to [idle v]
else
if <(frame) = [-1]> then
switch costume to [crouch v]
else
switch costume to ([floor v] of ((1) + ((frame) mod (8)))


Is it okay if you remix the game so I see what you mean? I'm sorry if I'm bugging you.
Ah, sorry, but I'm afraid I'd rather not make remixes for script help right now…

What I mean is that just like how
when you don't press any key, “frame” is set to 0,
you could make it so that
when you press S, “frame” is set to -1.

Then, just like how the custom Set Costume block
switches the costume to ‘Idle’ when “frame” is 0,
it could also
switch costume to ‘Crouch’ when “frame” is -1.

Sorry if i'm still not being clear…
ramenosu
Scratcher
55 posts

Does anyone know how to make a sprite crouch?

Alright. I'll try.
ramenosu
Scratcher
55 posts

Does anyone know how to make a sprite crouch?

semmiesem9 wrote:

ramenosu wrote:

semmiesem9 wrote:

I would add a -1 frame for crouching, and place it before or after the A or D key inputs depending on whether you want it to prioritize crouching on moving.

if <key [s v] pressed> then //place this with the other keys
set [frame v] to (-1)
else
... //either the entire A/D/else inputs or the "set frame to 0"
end

Then change to the crouching sprite in the Set Costume block.

if <(frame) = [0]> then
switch costume to [idle v]
else
if <(frame) = [-1]> then
switch costume to [crouch v]
else
switch costume to ([floor v] of ((1) + ((frame) mod (8)))


Is it okay if you remix the game so I see what you mean? I'm sorry if I'm bugging you.
Ah, sorry, but I'm afraid I'd rather not make remixes for script help right now…

What I mean is that just like how
when you don't press any key, “frame” is set to 0,
you could make it so that
when you press S, “frame” is set to -1.

Then, just like how the custom Set Costume block
switches the costume to ‘Idle’ when “frame” is 0,
it could also
switch costume to ‘Crouch’ when “frame” is -1.

Sorry if i'm still not being clear…


It doesn't seem to work?? I'll mess around with it.
plop23456123
Scratcher
1 post

Does anyone know how to make a sprite crouch?

I would make a costume that looks like he is crouching and make a variable “state”. Then I would put under the when green flag clicked if key down arrow pressed set state to crouch, wait 1 second, set state to idle. and if the state is crouch (in a separate line of code) switch costume to “crouch” or whatever you named your costume that looks like he is crouching.
Wyan100
Scratcher
1000+ posts

Does anyone know how to make a sprite crouch?

I would just do this:

forever
if <key [Crouch Button] pressed?> then
switch costume to [Crouch]
else
switch costume to [Not Crouch]
end
end

but I didn't look at the project so I'm not sure how this would work.
potatohead_1011
Scratcher
100+ posts

Does anyone know how to make a sprite crouch?

plop23456123 wrote:

I would make a costume that looks like he is crouching and make a variable “state”. Then I would put under the when green flag clicked if key down arrow pressed set state to crouch, wait 1 second, set state to idle. and if the state is crouch (in a separate line of code) switch costume to “crouch” or whatever you named your costume that looks like he is crouching.
I'm sorry to inform you but the question was asked one year ago.
osb21313
Scratcher
80 posts

Does anyone know how to make a sprite crouch?

To do it, Use this:
when green flag clicked
switch costume to [down]
wait until <not <key [down arrow] pressed?>>
switch costume to [idle]

Last edited by osb21313 (May 16, 2021 21:21:10)

TheAnomalousPseudo
Scratcher
1000+ posts

Does anyone know how to make a sprite crouch?

osb21313 wrote:

To do it, Use this:
when green flag clicked
switch costume to [down]
wait until <not <key [down arrow] pressed?>>
switch costume to [idle]
Please don't necropost. The original post is two years old.
Harakou
Scratcher
1000+ posts

Does anyone know how to make a sprite crouch?

osb21313 wrote:

To do it, Use this:
when green flag clicked
switch costume to [down]
wait until <not <key [down arrow] pressed?>>
switch costume to [idle]
Hi! Thank you for offering your help, but this thread is pretty old - I don't think it's relevant anymore. When you respond to a topic, please make sure it's recent and the original poster still needs an answer. Thanks!

Powered by DjangoBB