Creating the User Controls
The constructor method of GameView.java has several newcomers. This section dissects the new sprites that are used primarily for user interaction and also shows you a new concept. Rather than create four different cannon icons that point in all of the cardinal directions, you rotate one image for the four different sprites. This saves space on your machine, but it also causes some extra processor work at startup.
To demonstrate the alternative, the main cannons are all individual sprites that don’t need to be rotated. The method you use on such occasions depends on your resources and how much space you have on disk.
Follow these steps:
1. Before you can start working with the new sprites, you must first declare the ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access