[MUSIC] This is a tutorial for learning how to use the MotionHUD CocoaPod. HUD stands for HeadsUpDisplay. This is a CocoaPod that we wrote in order to help facilitate one of our deliverables. So the motivation here is recognizing the fact that in a remote online course like this, if we're asking you to demonstrate the physical moving of a device by recording your device screen, it's very hard to demonstrate that. Because when you record the video of your app running on the device, regardless of how much you move the device, the video itself remains stable. And yet, if we're asking you to do things that respond to rotation, we need to do something to help you out. So in this diagram here, it shows the device on the right shaking and moving, and on the left it shows the recording that would result from shaking and the moving of that device. And it would just be still because the recording is relative to the device, not to the world. So in order to help us grade these assignments, what we did is we created something called the Motion HeadsUpDisplay. And what it's going to do is it's going to put a small little indication that your device is moving, overlaid on top of your graphics. The way we're going to bring this into our application is by including a CocoaPod. The CocoaPod's name is MotionHUD. The way you use it is you subclass your game scene from the MotionHUD class, MHMotionHUDScene. And then, any time you have anything in an update routine in that particular scene, you just have to make sure that the first thing that you do is you call the superclass in order to make sure that the update of the overlay is working. So let's go ahead and do that with the previous app that we made, the platformer, Martha's World, the Gnome and the Mushrooms, and let's demonstrate how you get that HeadsUpDisplay to show, okay? So let's go ahead and I'm going to go to the directory where the game is. So we are in the directory here where Martha's World is located. And if we bring it up here in Xcode, this is the game. So this is the game before we tried to put this CocoaPod in. So now what I'm going to do is I'm going to go ahead and pod init in this directory in order for it to make it CocoaPod aware. If all goes well, I'll get a pod file. And then I'm going to edit that pod file to include [NOISE] to include the pod MotionHeadsUpDisplay. I'm going to save that file, I'm just going to hit pod update to make sure that I get the most recent version of the CocoaPod. We're probably going to need to make some changes to the CocoaPod, as we see it get deployed more and more, if we find that there are any bugs in it. We'll update it, and doing pod update is the way that you can get the most recent updates of the CocoaPod. So doing this is not just updating this one CocoaPod, but it is going out, getting a list of all the most recent versions of all the CocoaPods that are available, so it can take a few seconds. We'll give it a second to update, and then as soon as it's done updating we're going to go ahead and do PodInstall. And PodInstall will go out and get the very specific CocoaPods that we have asked for. Actually, UpdatePods went ahead and did it. So it doesn't hurt at all to go ahead and do PodInstall again. We are on version 1, 0.1.2 right now. All right, so now meanwhile, back in our project, you can see it's been updated to be CocoaPod aware. But I'm not sure I opened the right thing when this was opened. So I'm going to close it, I'm going to show it here, and I'm going to go ahead and open the workspace version. There we go. All right, go into our code. All right, so that was the first thing. That was including the CocoaPod, doing podUpdate, podInstall. Now what I need to do is I need to subclass my scene from the MotionHUD class instead of from the SKScene if that's what was happening. So let's go do that. That's going to be located in our gamescene.h file. And I'm going to go ahead and remove the reference to SKScene and make my class subclassed on MHMotionHUDScene. Now we have to make sure that the compiler is aware of that code. And so we're going to go ahead and have an import line to import the heterofile from the CocoaPod that was installed, okay. So that's subclassing our class. And then the last thing that we have to do is we have to make sure that within that game scene, that anytime we call update, we're calling the update on the super class, so that the sensors get updated, so the sensor display gets updated. So that's going to be in GameScene.m, down here at the bottom. And because I'm not doing anything in update, I don't need to do this. If you override update, you have to make sure that you call the super class. So if I had gotten rid of this method entirely, my game would work and the super class would be getting called. But just to make it clear that this is something that you need to do, I went ahead and instantiated an update class, all right? So this code here calls the visualizer. All right, now if all goes well, we should be able to run this in our simulated device and we should see that the MotionHeadsUpDisplay is being overlaid on top of the graphics. And we'll just need to wait for that to come up. Here it is. All right, here's our game. This is the simulator. It's loading up. And what you can see down there at the bottom, way down here, there's that little circle, and those little bars. And there's [SOUND] whoop, it's running a little slow. [SOUND] There you go. Well, let's see if we can get it to move. [SOUND] In the simulator I can't do a double-click easily to get the gnome to jump. But that's a HeadsUpDisplay down at the bottom. Now this is exactly the problem, that if we're running in the simulator we can't get any input from that HeadsUpDisplay. So what I'm going to do is I'm going to stop the simulator, and I'm going to go ahead and I'm going to try and run it on an iPad that's physically connected to my computer right now. Before I do that, let me see if I can get QuickTime to mirror the screen for us. I always have trouble doing this once the video has started. But let's give it a shot. Okay, where'd it go? That's what's on the screen, right. That's my graphics. All right, so now let's go to this one and run the game on the actual device. And we'll go back and we'll see what's happening on our screen here. I'm not going to record it. I'm just going to keep track of it. Back to my main screen. And if all goes well, Martha's World will get launched. We're loading. All right, now I've got the physical device and you can see that as I move the device physically, I'm not sure you can see that, that the little bars in the back are updated to sort of show you that even though the recording is stable that something is going on with the device. That when I add the appropriate interaction, it will enable me to identify that the device is actually moving. And so you can evaluate that. Yeah, the device is moving. And I can see that something is happening in the game. Now in my game, nothing's happening right now when I move the device, except for the MotionHeadsUpDisplay, okay. I'm going to set down my game there and close a QuickTime viewer. Back to our keynote. Okay, so that's it. It's a pretty easy CocoaPod to use. It's just something that's going to help us identify to make sure that you're meeting the requirements of the sensor portion of the assignment. Okay, thank you for your attention. Good luck. Let us know if you have any trouble getting this thing to work. [MUSIC]