This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2010-03-25 16:56:42

fireballman
Scratcher
Registered: 2010-02-17
Posts: 14

How do I get this to work...?

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]


There are only 10 types of people in the world: Those who know binary and those who don't.

Offline

 

#2 2010-03-25 17:21:03

16Skittles
Scratcher
Registered: 2009-08-26
Posts: 1000+

Re: How do I get this to work...?

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)


http://16skittles.tk/sig.png
Are you a student? Check out OnSchedule!

Offline

 

#3 2010-03-25 20:31:17

nXIII
Community Moderator
Registered: 2009-04-21
Posts: 1000+

Re: How do I get this to work...?

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)


nXIII

Offline

 

#4 2010-03-30 09:36:35

fireballman
Scratcher
Registered: 2010-02-17
Posts: 14

Re: How do I get this to work...?

Thanks


There are only 10 types of people in the world: Those who know binary and those who don't.

Offline

 

Board footer