1 00:00:01,250 --> 00:00:06,760 The first thing you want to study about touches or tormenter It's called the begin and touches. 2 00:00:06,770 --> 00:00:08,550 And that actually is rather simple. 3 00:00:08,660 --> 00:00:13,470 So let me go to Rick Scott and I'm going to start the new application. 4 00:00:13,490 --> 00:00:24,540 I'm going to call them torches began and ended. 5 00:00:24,710 --> 00:00:28,400 So let's assume I have something in my head. 6 00:00:28,430 --> 00:00:29,620 Very simple. 7 00:00:29,620 --> 00:00:37,240 You I view and there is that I use the you I view one not any other kind of object even though they 8 00:00:37,240 --> 00:00:41,980 all almost work similarly Is that your views by default. 9 00:00:41,980 --> 00:00:45,140 They have their user interaction enabled. 10 00:00:45,310 --> 00:00:50,770 So if you have an object then you are trying to interact with and you're trying to tap into tagine and 11 00:00:50,800 --> 00:00:52,000 that doesn't work. 12 00:00:52,060 --> 00:00:58,180 Make sure that you have the user interaction enabled that is not enabled by default for some of the 13 00:00:58,180 --> 00:01:00,370 objects such as you or image view. 14 00:01:00,500 --> 00:01:05,280 But for a view it is by default virtually simplifies what I'm doing right now. 15 00:01:05,740 --> 00:01:08,340 I also got to go ahead an other outlet for this. 16 00:01:08,500 --> 00:01:15,240 So that's something you know we know we should be doing this out of there's going to be red box and 17 00:01:15,250 --> 00:01:17,710 that's all I'm going to do in my interface. 18 00:01:19,300 --> 00:01:21,780 So here I don't need to view that lot. 19 00:01:21,780 --> 00:01:26,900 The only methods I need are all my tools that are members of the UI kit. 20 00:01:26,920 --> 00:01:29,430 So I could have them built into it. 21 00:01:29,430 --> 00:01:33,240 One of them is called touches began. 22 00:01:33,870 --> 00:01:35,990 And the other one is called touches. 23 00:01:36,090 --> 00:01:39,610 And as you can see we have two other ones has moved on. 24 00:01:39,620 --> 00:01:42,540 Can we talk about it in our next lesson. 25 00:01:42,750 --> 00:01:52,040 So this one is pouches and let me reformat everything so I can show them to you easier and tray to myself 26 00:01:52,070 --> 00:01:53,050 easier. 27 00:01:53,570 --> 00:02:01,490 So what happens is that whenever a touch lands on the surface of your iPhone this method gets called 28 00:02:01,700 --> 00:02:04,070 and whenever a touch leaves your surface. 29 00:02:04,100 --> 00:02:05,660 This one gets called. 30 00:02:05,760 --> 00:02:09,120 Now do something really really simple and easy. 31 00:02:09,170 --> 00:02:16,810 I'm going to have to say if I touched this red box remove it from the screen I simple as that. 32 00:02:16,880 --> 00:02:24,700 So the first thing is I'm going to say Let my touch to become touches first. 33 00:02:24,830 --> 00:02:30,350 So there is a set of different touches that might have landed or leaving the screen. 34 00:02:30,350 --> 00:02:33,970 In this case and I'm going to get the fake first one of those. 35 00:02:34,010 --> 00:02:44,150 So I'm going to get the one off the touches then I'm going to say if my torch view is a red box if I 36 00:02:44,150 --> 00:02:49,400 have touched under the box because otherwise I don't want to do something. 37 00:02:49,400 --> 00:02:53,990 Now let me show you a little trick that you could do something else you could do and that is if you 38 00:02:53,990 --> 00:03:01,550 want to touch a variety of different options objects you could say if might touch view is not self view. 39 00:03:01,610 --> 00:03:03,640 But for now we don't care about that. 40 00:03:03,650 --> 00:03:06,880 We care about the red box. 41 00:03:07,010 --> 00:03:14,660 So if might touch view is the red box here is what you want I want to say red box does that remove from 42 00:03:14,740 --> 00:03:15,410 superb. 43 00:03:16,510 --> 00:03:18,690 And that's pretty much all there is to it. 44 00:03:18,760 --> 00:03:27,210 If you want they put right something in the touches began as I like to say clean touch land. 45 00:03:27,640 --> 00:03:40,380 So we know when it touch lands and when something happens let's go ahead and run this up on our simulator. 46 00:03:40,400 --> 00:03:47,390 So now I'm going to show you what gets printed in my console because if I touch somewhere outside the 47 00:03:47,390 --> 00:03:54,460 red box is still something should be printed because the touches began doesn't test to see which you 48 00:03:54,560 --> 00:03:55,230 are on. 49 00:03:55,370 --> 00:04:00,410 So if it happened yet it says to touch land at the top again it says a touch on that. 50 00:04:00,530 --> 00:04:03,620 But the very top under it it says a touch on that. 51 00:04:03,920 --> 00:04:08,840 You can see it but then instead of holding the mouse button and not letting go of it it's as if I have 52 00:04:09,180 --> 00:04:13,080 pressed put a touch on the device and I'm not letting go of it. 53 00:04:13,160 --> 00:04:19,640 The moment they let go of it it removes it simply because when I said that it did the same. 54 00:04:19,640 --> 00:04:24,290 It says if my touch was was removed from Superbia. 55 00:04:24,620 --> 00:04:32,780 So that's about the very basics of using touches of this very limited you know introduction. 56 00:04:32,850 --> 00:04:39,500 There is still so much you can do a lot of you know simple games you can develop you can do things that 57 00:04:39,530 --> 00:04:46,390 are about the number of touches you can count the time between different touches so on and so forth. 58 00:04:46,400 --> 00:04:49,720 So let's keep it up to here and move on to our next lesson.