My animation and motion scripts are really glitchy
The script for movement is
[blocks]
<when[down arrow]key pressed>
<forever>
<point in direction(180)>
<switch to costume[ Pikachu Forward] >
<move(10)steps>
<if><key[Right Arrow]pressed?>
<stop all>
</if>
<if>
<key[Left Arrow]pressed?>
<stop all>
</if>
<if>
<key[Up Arrow]pressed?>
<stop all>
</if>
<wait(0.1)secsc>
<switch to costume[ Pikachu fwd rt ft]
<move(10)steps>
</if>
<if>
<key[Right Arrow]pressed?>
<stop all>
</if>
<if>
<key[Left Arrow]pressed?>
<stop all>
</if>
<if>
<key[Up Arrow]pressed?>
<stop all>
</if>
<wait(0.1)secsc>
<switch to costume[ Pikachu Forward]
<move(10)steps>
</if>
<if>
<key[Right Arrow]pressed?>
<stop all>
</if>
<if>
<key[Left Arrow]pressed?>
<stop all>
</if>
<if>
<key[Up Arrow]pressed?>
<stop all>
</if>
<wait(0.1)secsc>
<switch to costume[ Pikachu fwd rt ft]
<move(10)steps>
<if>
<key[Right Arrow]pressed?>
<stop all>
</if>
<if>
<key[Left Arrow]pressed?>
<stop all>
</if>
<if>
<key[Up Arrow]pressed?>
<stop all>
</if>
<wait(0.1)secsc>
</forever>
[/block]
Scratch blocks don't like me D: Anyway, here it is, Any tips?
http://scratch.mit.edu/projects/bekahthepika/602275
Offline
I couldn't understand all the scripts, but I'm guessing your main problem is the over used "stop all" <stop all> and "when blank key pressed blocks" <when[ ]key pressed> .
The script I use for motion is:
<when green flag clicked>
<forever>
<if><key[ down arrow ]pressed?>
<change y by( -5
<end>
<if><key[ up arrow ]pressed?>
<change y by( 5
<end>
<if><key[ left arrow ]pressed?>
<change x by( -5
<end>
<if><key[ right arrow ]pressed?>
<change x by( 5
<end>
It's possible that one of your problems is that the stop all block won't ever stop the when down arrow key pressed control block because every time the down arrow is pressed the script is started all over.
If you use the above script and wanted to add animation, you could add a "switch to costume __" below the move blocks. If you wanted the animation to take place when to keys are pressed, all you have to do is say:
<if><< <key[ Down ]pressed?> <and> <key[ Up ]pressed?> >>
I hope I could help!
Offline