Book Image

App Inventor 2 Essentials

Book Image

App Inventor 2 Essentials

Overview of this book

App Inventor 2 will take you on a journey of mobile app development. We begin by introducing you to the functionalities of App Inventor and giving you an idea about the types of apps you can develop using it. We walk you through the technical set up so you can take advantage of the interactive development environment (live testing). You will get hands-on, practical experience building three different apps using tutorials. Along the way, you will learn computer science principles as well as tips to help you prepare for the creative process of building an app from scratch. By the end of the journey, you will learn how to package an app and deploy it to app markets. App Inventor 2 Essentials prepares you to amass a resource of skills, knowledge and experience to become a mobile app developer
Table of Contents (15 chapters)
App Inventor 2 Essentials
Credits
About the Authors
About the Reviewer
www.PacktPub.com
Preface
Index

Updating the Play button


When we built the Play button, the blocks resembled the following screenshot:

But now, we want to redo the Play button blocks because we no longer want the Play button to set the ball's x random location. Instead, we want the Play button to get the location of the ball from the Reset button. This way, when the Play button is pressed, the ball will just begin moving from where it already is, having just been reset to the top of the screen by the Reset button between the very first time a user plays the game, the Play button will set the random location of the ball using the blocks we already programmed. Then the first time (and ensuing times) that the Reset button is pressed and sets the location of the ball at the top of the screen, we want the ball to start moving from that location when the Play button is pressed.

At this point, it might be obvious that we will use an if/then/else event block. The reasoning, however, is a little counter-intuitive. The only time the...