In today's tutorial, we are going to repeat quickly some of the Day 1 tutorial. Today, we are going to add some buttons on the app. These buttons will change the speed and heading properties of the bouncing ball directly from the app instead of having to manually change them in the app inventor.
We are also going to add a text label which will show us the ball's current speed and heading.
We are going to quickly rebuild the bouncing ball app we made in Day 1.
It is time to make the ball bounce. The following steps are done exactly as they were in Day1.
The ball1 should be bouncing back and forth, left and right on your screen.
In Day1 we changed the speed of ball1 by changing its properties in the app inventor. Now we are going to make a button to do that for us.
Notice how every time we add component from the pallet to the viewer it gets a number next to its name? If we added 3 more buttons what would they be called? It is important to know that we can rename these to whatever is useful for us. Renaming them helps us keep track of them for later. Let's rename them.
Lets repeat the steps we followed for Button_SpeedUp for Button_SpeedDown.
This time, instead of doing +1, we want -1. Create this block set up:
Labels handle text. You can change what text they display by changing the Text field on the properties window or by giving them values in the blocks editor.
Here are some hard things to try to do. If you don't want to try any of these, or are finished:
Regular Challenge: Make two new buttons. One that increases ball1's heading by 10 and one that decreases it by 10 every time you click them.
Super Hard Challenge: Can you make it so you can fling the ball around by using your finger?
Super SUPER Hard Challenge: Having completed Regular Challenge, make a little game where you "drive" ball1 around the canvas collecting objects that increase your "score." This will take a lot of time and planning.
Developers Debugger Challenge: Figure out why the ball doesn't bounce when its speed has a negative value. Is there a solution or work around for this? Note: Mr. Incorvia does't know the answer to this... yet.
Middle School Android App Inventor Tutorials by Richard Incorvia is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License.