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

Changing the game's dynamic


As the game stands, the ball is moving downward and whenever your finger touches it, it will get flung in another direction (to be exact, 360 degrees minus the direction it was heading). We can program the app so the ball only responds to a fling when it is below the middle of the screen. Can you guess how we might program this? If you guessed using an if/then block, you're on the right track! If the ball is below the middle of the screen, then it can be flung.

Currently, our blocks look like the following screenshot:

We want to tell the app to first check and see whether the ball is below the middle of the screen. We've coded something similar if you recall when we used the Screen1.Width block. Since we won't know the screen size of every user, we cannot just input a specific number and divide it by 2. But we can get the user's screen size with the Screen1.Height block and divide this by 2. In Chapter 3, Navigating the App Inventor Platform, you also learned that...