02Geek HTML5 and JavaScript, TypeScript, React, Flash, ActionScript online School
Previous VideoNext Video

Type 2: Click Ads

Click ads are static and hang like banners until the user clicks through to another window. Unlike time based ads, these are great to integrate into a main menu screen or a game that has enough space to place an ad.

Video Transcript

00:00So let's move to the next type of ad type.
00:03We've seen the show interval ad, and we've
00:05seen how it works, where it's a time limited ad, which
00:08then we could then call our ad finished
00:12and continue to the next experience in our site.
00:15Now what if we wanted to create an ad that would just
00:18be static in our sites?
00:19For example, when our application begins,
00:22what if we just wanted a banner there waiting
00:25until the user clicks on the star button?
00:28To do that is very easy with this ad network as well.
00:32What I want to do is I just want to copy so we
00:34could reuse some of this code.
00:36I just want to copy all of these lines
00:38from the creation of our interval ad,
00:41and we'll see how simple it is to actually recreate
00:44a very similar experience, only this time we're just
00:47going to put a banner that never goes away
00:49until we explicitly tell it to go away.
00:52So to do that, I'm going to create a new private function,
00:55and I'm going to call it ad claims ads y value,
01:00plus whatever the width of the ad is, which we don't really
01:04know more or less, so we're just going to guesstimate it.
01:06We're going to put here about 260.
01:09And let's see what happens if it's
01:10positioned in a position that we're happy with.
01:13And I'm quite happy with that, so it's
01:14giving you a little bit of margin.
01:16Maybe I would put a little bit more.
01:22And now we're great.
01:24So our start button will just come randomly
01:26throughout our application right here.
01:28Now, we have one problem.
01:29If we start our application, we're
01:31going to see that our ad is stuck in its place,
01:36and we don't really want that ad to be there.
01:38So to get rid of the ad before we move on to our start,
01:42what I want to do is go back into our onStart method,
01:48and then in our onStart method, before we're
01:52going to even call our new banner,
01:57I want to get rid of MCAds.
02:00And if I run my application one more time,
02:03ooh, I had a little spelling error there.
02:05And again, let me just, all righty.
02:15So if we run our application one more time, first of all,
02:18we'll get our banner.
02:20When we click our start, it's going
02:21to get rid of the previous banner.
02:23Then it's going to load in a new banner.
02:25And when that banner will be completed,
02:27then our game will begin.
02:29Now, we have only one more thing that's missing,
02:31is we want to make sure that when our game is complete,
02:33that our startup banner will come up again.
02:37And to do that, we could just reuse our method
02:39that we just created, and that's why we extracted it
02:41and put it inside of a ad click ad.
02:44We could probably copy this whole thing, all of this,
02:47and just go all the way to the end of our game
02:49and find where we're calling, again,
02:51our start button, which should be just about here.
02:58And right after we called our end function
03:00and we added a new start button, we just
03:02want to add this logic again, making sure
03:04that when our game will restart again,
03:07it will restart with a new start button.

Ready to Level Up Your Skills?

Join thousands of learners on 02GEEK and start your journey to becoming a coding expert today!

Enroll Now for Free!