Basic classes mini-app
The hypothetical real-time strategy (RTS) game we are writing will need more than one Soldier
object. In our game that we are about to build we will instantiate and use multiple objects. We will also demonstrate using the dot operator on variables and methods to show that different objects have their own instance variables contained in their own memory slot.
You can get the completed code for this example in the download bundle. It is in the chapter 8/Basic Classes
folder. Or read on to create your own working example from scratch.
Create a new project and call the application BasicClasses
. Choose the Empty Activity template. Call the Activity RTSActivity
. As usual, we don't need the Generate Layout File or Backwards Compatibility ...
Get Learning Java by Building Android Games - Second Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.