Trimming the sprite sheet
In order to have RHB crash into a stone, we're going to have to deal with the transparency. Let's take a look at the raw .png
file that RHB is coming from. A portion of the image is shown in Figure 5.8, as follows:
This is two frames of the idle animation, with black lines showing the image borders. As you can see, there is a ton of extra space in these images, so using a bounding box that's the same size as the image won't work. That's the problem you see with the bounding boxes in Figure 5.7. We have two choices to fix it. The simplest, although annoying, would be to open our sprite sheet in a graphics editor and find out the actual pixels for the bounding boxes for each sprite. Then, we would store that in code or a separate file and use those bounding boxes. That's faster in development time, but it means loading a much larger image than is necessary and rendering...