Page 255 - Scratch Programming Playground
P. 255
fortunately, we can fix this problem by using the hitbox
concept we used in the Basketball game.
9. Add a Hitbox Costume to the Cat Sprite
Click the Cat sprite’s Costumes tab. then click the Paint
new costume button and draw a black rectangle that covers
most (but not all) of the area of the other two costumes. the
following figure shows a slightly transparent first costume in
the same image so you can see how much area the black rect-
angle covers.
Name this costume hitbox. Whenever the Platformer pro-
gram’s code checks whether the Cat sprite is touching the
Ground sprite, we’ll switch the costume to the black rectangle
hitbox costume before the check and then back to the regular
costume after the check. By doing so, the hitbox will determine
whether the cat is touching the ground.
MakING aN advaNCed pLatforMer 229

