Pong Game - 2D Animations and Gestures

Animations are an important feature that you can add to your apps to make them more attractive. They make it possible to add important functionality in a way that is pleasant for your users. For example, you could use animations to notify the user that an action has been completed, or you can use them to get user input. In any case, animations are often required to give your apps a polished look that can help make them successful. The good news is that Flutter has very good support for animations.

If you are like me, you probably love games, and usually, animations are what games are made of. So, in this chapter, we'll build a simplified single-player version of the ancient Pong game. We'll build a ball that will bounce through the screen, and we'll use a bat to avoid it touching the bottom part of the screen.

Building this game will give us the opportunity to see in detail how animations work in Flutter. We will also see how to add gesture detection to your widgets, another important feature. Finally, we'll add some randomness to the game to make it a bit more interesting.

As usual, we'll start from scratch. The result will probably not be something you would publish to the stores, but I believe it can be a fun way to see animations in an unconventional way and a good starting point to think about the logic of a game.

The time required for this project is approximately 2 hours and 30 minutes.

In particular, the topics we will cover include the following:

  • Using Stack and Positioned to build the user interface
  • Using Animation and AnimationController to build Tween animations
  • Using GestureDetector
  • Using Random() from the Dart Math library
..................Content has been hidden....................

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