﻿1
00:00:04,190 --> 00:00:05,790
‫Hey, welcome back.

2
00:00:05,810 --> 00:00:10,150
‫We are ready to show our countdown time in the actual widget.

3
00:00:10,160 --> 00:00:15,530
‫So far, we're only using print string nodes so that we know how much time is left.

4
00:00:15,530 --> 00:00:18,950
‫But we need to actually set the text in the widget.

5
00:00:18,950 --> 00:00:23,150
‫So we're going to show the countdown time in the widget in this video.

6
00:00:23,180 --> 00:00:30,710
‫Now I'm back here in WP Start Game Widget and we saw that we added some text to this widget.

7
00:00:30,710 --> 00:00:36,770
‫And there are a couple of things we need to change with this text widget so that we can edit the text

8
00:00:36,770 --> 00:00:37,930
‫dynamically.

9
00:00:37,940 --> 00:00:41,840
‫The first thing I'd like to do is with the text widget selected here.

10
00:00:41,840 --> 00:00:48,800
‫Here in the details panel, there is a name for this text and it's set to a default name, which is

11
00:00:48,800 --> 00:00:50,000
‫not very descriptive.

12
00:00:50,000 --> 00:00:58,310
‫So I'd like to rename this and let's call this display text now right next to this text block, we can

13
00:00:58,310 --> 00:01:01,310
‫see this checkbox that says is variable.

14
00:01:01,340 --> 00:01:02,960
‫Now it's not checked.

15
00:01:02,960 --> 00:01:09,770
‫And if we go back to the event graph section, we don't see this text widget as a variable here.

16
00:01:09,770 --> 00:01:15,950
‫But if we go back to designer and check this text box is variable, then once we go back to the graph,

17
00:01:15,950 --> 00:01:23,300
‫we'll see that display text is now visible in the variables section and we can click and drag off and

18
00:01:23,300 --> 00:01:29,810
‫click get display text here and now we have access to this node, which means we can change the text.

19
00:01:29,810 --> 00:01:36,110
‫Now I'd like to drag this down to Case three in our switch statement where we're printing the string.

20
00:01:36,110 --> 00:01:42,650
‫Get ready to the screen now instead of using a print string, I'd like to set the text for our text

21
00:01:42,650 --> 00:01:48,380
‫widget and I can do that by dragging off of its output pen and typing set text.

22
00:01:48,380 --> 00:01:52,700
‫And here we see a set text in parentheses text node.

23
00:01:52,700 --> 00:01:58,700
‫If I click that, then I get a set text node and here is an input called in text.

24
00:01:58,700 --> 00:02:05,450
‫Now it takes an input value of type text, but we can also click the text box here and hard code the

25
00:02:05,450 --> 00:02:07,610
‫value we'd like to set the text to.

26
00:02:07,640 --> 00:02:09,440
‫So I'm going to type get ready.

27
00:02:09,440 --> 00:02:15,260
‫And rather than using this print string, I'm going to remove that print string and drag the case three

28
00:02:15,260 --> 00:02:20,930
‫execution wire into the input execution pin for the set text node.

29
00:02:20,930 --> 00:02:27,140
‫Now if I compile and hit play, I'll see that it says Get ready, which is the same text that it was

30
00:02:27,140 --> 00:02:27,770
‫before.

31
00:02:27,770 --> 00:02:34,250
‫So it doesn't look any different, but we can prove that it is using the text in the set text node.

32
00:02:34,250 --> 00:02:37,520
‫By changing this, I'll add a couple of exclamation points.

33
00:02:37,520 --> 00:02:38,780
‫So there are three of them.

34
00:02:38,780 --> 00:02:42,380
‫And now if I hit play, I see three exclamation points.

35
00:02:42,380 --> 00:02:47,690
‫So this node is in fact setting the text for our text widget.

36
00:02:47,990 --> 00:02:54,590
‫So I'm going to challenge you to set the text so that we can print a different message for each of the

37
00:02:54,590 --> 00:03:01,880
‫cases in our switch statement for three, you can leave it at get ready for to print the text to to

38
00:03:01,880 --> 00:03:05,390
‫the screen for one, print one and for zero.

39
00:03:05,390 --> 00:03:12,170
‫I'd like you to print go now for the default case, which is when we've run out of time, just print

40
00:03:12,170 --> 00:03:16,910
‫an empty string, which means you can leave that input text box blank.

41
00:03:16,910 --> 00:03:23,150
‫So pause the video and remove those print strings and replace them with a set text node.

42
00:03:23,150 --> 00:03:26,870
‫And don't forget to plug in the input to the set text node.

43
00:03:26,900 --> 00:03:29,820
‫The value from our text widget.

44
00:03:29,840 --> 00:03:32,240
‫Pause the video and do this now.

45
00:03:36,200 --> 00:03:41,480
‫So I'd like to use this set text node and I'm going to highlight both of these nodes so they're both

46
00:03:41,480 --> 00:03:43,280
‫selected and hit control.

47
00:03:43,280 --> 00:03:47,840
‫D To copy that and I'm going to use the zero case.

48
00:03:47,840 --> 00:03:51,290
‫I'm going to just hook it straight up to the set text node.

49
00:03:51,290 --> 00:03:59,000
‫And rather than printing go with a print string, I'm going to print go by setting the text to go and

50
00:03:59,000 --> 00:04:01,550
‫now I can remove this print string.

51
00:04:01,580 --> 00:04:05,600
‫Now I need to set the text for cases one and two.

52
00:04:05,600 --> 00:04:14,840
‫So I'm going to copy this set text node and hook up the one case and simply print one and remove that

53
00:04:14,840 --> 00:04:15,650
‫print string.

54
00:04:15,650 --> 00:04:21,920
‫Now, I'm going to move these nodes out of the way so that I can add another set text node and hook

55
00:04:21,920 --> 00:04:25,970
‫up two to this one and use two as the text.

56
00:04:25,970 --> 00:04:33,740
‫And I can remove that print string and finally I can replace the start game with an empty string.

57
00:04:33,740 --> 00:04:40,400
‫So I'm going to hook up the default to another set text and simply use no text so that we're setting

58
00:04:40,400 --> 00:04:42,260
‫the text to nothing.

59
00:04:42,260 --> 00:04:49,400
‫Now I'm going to remove that print string, compile and play and there is the countdown timer and it

60
00:04:49,400 --> 00:04:52,010
‫goes away as soon as the game starts.

61
00:04:52,010 --> 00:04:54,390
‫So that's exactly what we were after.

62
00:04:54,410 --> 00:04:55,910
‫Now, a couple of things.

63
00:04:55,910 --> 00:05:01,070
‫One is I'm going to go back to the designer tab and scroll down with the text selected.

64
00:05:01,070 --> 00:05:07,220
‫I'm going to scroll down to the appearance and you'll see that we have this justification and it's justified

65
00:05:07,220 --> 00:05:12,200
‫to the left, which is why the two and one get printed slightly to the left.

66
00:05:12,200 --> 00:05:19,790
‫But if I select a line text center now, if I hit play, I'll see that my text is aligned to the middle.

67
00:05:19,940 --> 00:05:22,790
‫Now we can give our text a shadow.

68
00:05:22,820 --> 00:05:24,680
‫Here we see shadow color.

69
00:05:24,680 --> 00:05:28,820
‫We can select that and we can give the text its own shadow.

70
00:05:28,850 --> 00:05:34,970
‫The alpha is set to zero, but if I drag it up to one now I have a shadow and now our text will have

71
00:05:34,970 --> 00:05:36,200
‫a black shadow.

72
00:05:36,200 --> 00:05:42,020
‫If I click play, then I can see that my text is a little bit more visible thanks to that shadow.

73
00:05:42,020 --> 00:05:43,040
‫So this is great.

74
00:05:43,040 --> 00:05:49,250
‫Let's go back into the Graph Tab and we now know that we're setting the text based on our countdown

75
00:05:49,250 --> 00:05:49,910
‫time.

76
00:05:49,910 --> 00:05:56,810
‫Now, this is all still happening, every single frame of the game since this is hooked up to the TIC

77
00:05:56,810 --> 00:05:57,500
‫event.

78
00:05:57,500 --> 00:06:04,400
‫But the truth is, we really don't need this widget to even exist after the 3 seconds are up.

79
00:06:04,400 --> 00:06:12,470
‫If there were a way to get rid of this entire widget and remove it, that would be more ideal than simply

80
00:06:12,470 --> 00:06:15,230
‫setting the text to an empty string.

81
00:06:15,440 --> 00:06:23,450
‫So to do that, what we can do instead of setting the text is we can remove this widget from the viewport.

82
00:06:23,450 --> 00:06:28,160
‫And to do that we use a node called remove from parent.

83
00:06:28,160 --> 00:06:34,100
‫So creating a remove from parent node and deleting the set text node.

84
00:06:34,100 --> 00:06:40,070
‫Then when we hit the default case, which is when that 3 seconds is up, then this node will result

85
00:06:40,070 --> 00:06:46,130
‫in the widget being removed and none of this tick functionality will be happening anymore because the

86
00:06:46,130 --> 00:06:47,480
‫widget will be gone.

87
00:06:47,480 --> 00:06:53,840
‫So this takes care of removing the widget once the timer is up and the player is able to start playing

88
00:06:53,840 --> 00:06:54,470
‫the game.

89
00:06:54,620 --> 00:07:01,880
‫So we have now showed the countdown time in our widget, which means that it's very clear when the game

90
00:07:01,880 --> 00:07:07,640
‫is starting and how much time has to pass before the player can start moving the tank around.

91
00:07:07,640 --> 00:07:08,690
‫This is great.

92
00:07:08,960 --> 00:07:10,820
‫So back to our section plan.

93
00:07:10,820 --> 00:07:15,380
‫We see that we've created our tank that can move throughout the world and handle input.

94
00:07:15,410 --> 00:07:23,090
‫We've created an enemy turret class called Tower in C++ and we've added fire functionality with projectiles.

95
00:07:23,090 --> 00:07:27,650
‫We have health and damage as well as destruction in our game.

96
00:07:27,650 --> 00:07:34,040
‫Now we still need to add special effects and we need to show when we win or lose the game using HUD

97
00:07:34,040 --> 00:07:37,280
‫displays, we've now seen how to use HUD displays.

98
00:07:37,280 --> 00:07:39,740
‫So this should be a relatively simple task.

99
00:07:39,740 --> 00:07:42,290
‫So we're almost done with this game.

100
00:07:42,350 --> 00:07:43,640
‫Congratulations.

101
00:07:43,640 --> 00:07:45,410
‫I'll see you in the next video.

