I am trying to get the last if statement to work but when you push down and p he either punches or crouches, he doesn't punch crouch. Does anyone have any ideas?
[blocks]
<when green flag clicked>
<forever>
<if> <key[ P ]pressed?>
<switch to costume[ punch ]
<else>
<if><key[ DOWN ARROW ]pressed?>
<switch to costume[ crouch ]
<else>
<if> << <key[ P ]pressed?> <and> key [ DOWN ARROW ]pressed?> >>
<switch to costume[ crouch punch ]
<else>
<switch to costume[ idle ]
[/blocks]
Offline
this bugged me in my video game camp when i first learned scratch.
try this script.
[blocks]<when green flag clicked>
<forever>
<if><key[ p ]pressed?>
<set{ punch? }to( yes )>
repeat that for crouch. then put If, elses for switching costumes like with
<if> <<(punch)=yes>and<.(crouch)=no>>
switch to costume punch
Last edited by 16Skittles (2010-03-25 17:23:27)
Offline
Your problem is that when the p key is pressed, it executes the first statement and doesn't even go to look at the second or third. If you put the punch crouch script as the FIRST statement, it will work. Try this:
[blocks]
<when green flag clicked>
<forever>
<if><< <key[ p ]pressed?> <and> <key[ down arrow ]pressed?> >>
<switch to costume[ crouch punch
<else>
<if> <key[ p ]pressed?>
<switch to costume[ punch
<else>
<if><key[ down arrow ]pressed?>
<switch to costume[ crouch
<else>
<switch to costume[ idle
<end>
<end>
<end>
<end>
[/blocks]
Last edited by nXIII (2010-03-25 20:34:02)
Offline
Thanks
Offline