Looking ahead at the Live Drawing app

As this app is more in-depth and needs to respond in real time, it is necessary to use a slightly more in-depth structure. At first, this may seem like a complication, but in the long run, it can even make our code simpler and easier to understand.

We will have four classes in the Live Drawing app:

  • LiveDrawingActivity: The Activity class provided by the Android API is the class that interacts with the operating system. We have already seen how the OS interacts with onCreate when the player clicks the app icon to start an app. Rather than have a class called MainActivity that does everything, we will have an Activity-based class that just handles the startup and shutdown of our app, as well as giving some assistance with initialization by getting the screen resolution. It makes sense that this class will be of the Activity type. However, as you will soon see, we will delegate interacting with touches to another class, the same class that will also handle almost every aspect of the app. This will introduce us to some interesting concepts that will be new to us.
  • LiveDrawingView: This is the class that will be responsible for doing the drawing and creating the real-time environment that allows the user to interact at the same time as his/her creations are moving and evolving.
  • ParticleSystem: This is the class that will manage up to thousands of instances of the Particle class.
  • Particle: This class will be the simplest of them all. It will have a location on the screen and a heading. It will update itself around sixty times per second when prompted to by the LiveDrawingView class.

Now, we can start coding.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.133.146.237