Page 261 - Scratch Programming Playground
P. 261

When the cat is standing still (that is, not moving left or
            right), the frame variable should be reset to 0. Modify the Cat
            sprite’s existing when green flag clicked script to add a third
            if then block that resets the frame variable.













                                              Be sure to put the green and block
                                             in the if then block first. You want the
                                             not blocks to go inside the and block.














                Now let’s write some code to deter-
            mine which costume to show. We’ll use
            this code in a few places in the scripts
            we’ve written, so let’s make a custom
            block.
                In the dark purple More Blocks cate-
            gory, click the Make a Block button
            and name this block set correct cos-
            tume. Click the gray Options triangle,
            check the option Run without screen
            refresh, and then click OK. add the
            following blocks to the Cat sprite, start-
            ing with the new define set correct
            costume block.








                                                           MakING aN advaNCed pLatforMer 235
   256   257   258   259   260   261   262   263   264   265   266