Virtual+Pet


 * This lesson will cove**r
 * The App Inventor environment[[image:forrestercomputing/cat.png width="116" height="243" align="right"]]
 * Components
 * Properties
 * Code (blocks)
 * Event-driven programming
 * Mobile features**
 * Touch interface
 * Working with sound

Your teacher will demonstrate a simple mobile app to you. This is the app that you are going to create – an on-screen virtual pet which you have to “care” for.
 * Introduction**

For video demostrations go here

Digital Resources go here


 * Items you might need**


 * //Picture//**

media type="file" key="meow.mp3" width="240" height="20"
 * //Audio//**


 * Task 1 - Design**




 * Task 2 - The Code**

Using either the Android emulator or live testing using a mobile phone, try out your app. Did it work as intended? If not, go back and check your code for any mistakes. If that doesn’t work, check the properties of your app’s components too.
 * Task 3: Testing your app**


 * Task 4: App Inventor reference sheet**

Please find the reference sheet task below. Print out or fill in in word.



This virtual pet reacts to being touched, rather than being stroked. Your teacher will now demonstrate how to replace the **Button** component with a **Canvas** component, which can detect a **drag** event. Now alter your app so that the cat meows only when it’s being stroked.
 * Extension Task 1**


 * Extension Task 2**

In the Blocks Editor, use a **Sound.Vibrat**e block from your sound component’s drawer, make your cat purr (i.e. make the phone vibrate) when you stroke under its chin!

In the Designer, add an accelerometer component (**Sensors→AccelerometerSensor**). Then add the code shown opposite so that your virtual pet works when you shake the phone.
 * Extension 3 – Cool Feature**