< Return to Video

Digital Doodle, MIT App Inventor Tutorial #4

  • 0:02 - 0:12
    ♩♫♪♬
  • 0:12 - 0:17
    Hey, welcome back. It's Shay and Emily and we are here with the third tutorial of the App Inventor Hour of Code.
  • 0:18 - 0:21
    - Hey Emily, I challenge you to a quick draw!
    - You're on!
  • 0:27 - 0:30
    Okay, that was childish but surprisingly fun.
  • 0:30 - 0:34
    Yeah. It's time for our next step and we just gave you a preview.
  • 0:34 - 0:40
    It's going to be a great app. For this app we are going to make a drawing canvas on the board where you can use your finger as a pen.
  • 0:40 - 0:42
    We call it "Digital Doodle".
  • 0:42 - 0:49
    Okay, back to the drawing board. Haha, get it? Drawing board... hum. Great. Here we go.
  • 0:49 - 0:52
    Once again, log on to App Inventor if you're not already there.
  • 0:53 - 0:57
    Start a new project. Name this one "DigitalDoodle".
  • 0:57 - 1:01
    Just like in the "Ball Bounce" app, you'll need a canvas to start.
  • 1:01 - 1:06
    But before we do that - do you remember the trick we learned for keeping the app from scrolling?
  • 1:07 - 1:12
    Right. Go into the properties for "Screen1" and uncheck "Scrollable".
  • 1:12 - 1:17
    Now add a canvas which you can find under "Drawing and Animation".
  • 1:17 - 1:24
    Go to the properties pane of the canvas and change the settings for both width and height to "Fill parent".
  • 1:24 - 1:26
    That opens up our canvas quite a bit.
  • 1:26 - 1:34
    Also, even tough we are not going to use it just yet, drag out an accelerometer component from the sensor drawer and drop that into your app.
  • 1:35 - 1:37
    Time to program the blocks!
  • 1:37 - 1:43
    Okay. So, the event that will detect someone's finger dragging on the canvas is pretty easy to guess.
  • 1:43 - 1:49
    Click on the canvas components' blocks and look around in the drawer. Can you figure out which block you need?
  • 1:50 - 1:54
    Right, you want the event handler for when "Canvas1" is dragged.
  • 1:54 - 2:00
    This event handler has a whole bunch of parameters. Don't worry - they're pretty easy to understand.
  • 2:00 - 2:05
    And, you can get on-screen help anytime just by mousing over a block. Like this.
  • 2:06 - 2:12
    Okay, great! So, we want to draw a line from wherever the finger drag was last to where it is now.
  • 2:12 - 2:18
    We'll essentially make the canvas draw hundreds of tiny lines between the points of the finger drag.
  • 2:18 - 2:21
    This will look just like drawing on the phone's screen.
  • 2:21 - 2:31
    But first we need that block that will draw a line. Go to "Canvas1" again and this time get the block that says to "call Canvas1.DrawLine".
  • 2:33 - 2:38
    Now, we need the X and Y coordinates of the beginning of the line draw to the end.
  • 2:38 - 2:44
    The "when Dragged" event will call "DrawLine" over and over while the finger is dragging on the screen.
  • 2:44 - 2:48
    We just need to provide the XY coordinates for these lines.
  • 2:48 - 2:51
    Go ahead and use previous X and previous Y.
  • 2:53 - 2:55
    You'll also need current X and current Y.
  • 2:58 - 2:59
    Now, go try out your app.
  • 3:00 - 3:01
    It should let you draw on the screen.
  • 3:03 - 3:09
    This app is great but wouldn't it be cool if you could shake to erase the screen rather than press a button?
  • 3:09 - 3:10
    Yeah, like Etch A Sketch.
  • 3:10 - 3:16
    Okay, It's Etch A Sketch time. Remember, we put in an accelerometer sensor into the components' list.
  • 3:16 - 3:18
    So now, we can program that.
  • 3:19 - 3:23
    Go to the accelerometer drawer and pull out "when Shaking".
  • 3:23 - 3:26
    The block we need to erase the screen is really simple to get.
  • 3:26 - 3:35
    Go to canvas and choose "call Canvas1.Clear". Plug that purple block right into the event handler for shaking.
  • 3:36 - 3:37
    Great! Test your app again.
  • 3:37 - 3:39
    Does your drawing erase when you shake it?
  • 3:39 - 3:46
    All right! So once again we've built a very simple app which can be extended in lots of fun ways.
  • 3:46 - 3:55
    The app that we demonstrated at the beginning of this tutorial lets you take a picture first and then put the picture on the canvas where you can draw on it.
  • 3:55 - 3:59
    You could also set up buttons to change the color of the ink used in the drawing.
  • 3:59 - 4:04
    All of these extensions are explained in the "PaintPot" tutorial on our website.
  • 4:04 - 4:11
    As you can see, there are endless possibilities of what you can build with App Inventor. It tabs into almost all of your phones capabilities.
  • 4:11 - 4:15
    You can even send and receive text and phone calls if you have a fully functional phone.
  • 4:15 - 4:19
    Even on a tablet over Wifi you can do some pretty cool things.
  • 4:19 - 4:24
    Thanks for joining us. If you're interested in learning more about App Inventor, go to the App Inventor website.
  • 4:25 - 4:26
    Happy Inventing!
  • 4:26 - 4:36
    ♩♫♪♬
Title:
Digital Doodle, MIT App Inventor Tutorial #4
Description:

more » « less
Video Language:
English
Duration:
04:40

English subtitles

Revisions