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

Type 1: Time Based Ads

Time based ads are the ones you'll find on Hulu.com or on television. They interrupt for a set amount of time, but once finished, your game automatically resumes. Learn how to integrate these ads into your game. They fit perfectly before a game starts or in between levels.

Video Transcript

00:00we created our movie clip and as we said the next step we want to figure out actually where do we
00:04want to put our first ad and before you could really look at it we need to understand that
00:08there are three different types of ads when we're working with the Mucci ad network
00:14and i'm sorry if i'm mispronouncing it i'm bad at pronunciations okay so basically there are
00:20three types of ads the first type of ad is a pre-loader ad for your game the second type
00:25of ad is a click through a click ad and the other one is a time-based ad
00:31let's start off with the click and time related ads because both of them are very similar and then
00:36we'll move back and look at the pre-loader ads which are for when your game begins and when your
00:42game is loading in i'm just going to run the application for one second because i want to
00:48just try to isolate and figure out where do we want to put our ad now specifically myself i want
00:53to put the ad when the user clicks on the start button and what i would want to do is create
00:58an ad that would stand there and as soon as the ad would be over then our game would begin
01:04now to do that i want i need to first figure out where in my game that would happen if we
01:09just scroll down a bit we're going to see that our on start happens when the user clicks on
01:13the start button that's basically where i would want to put my ad now i want to make sure that
01:18when the user restarts the game that they would get that ad again so if you scroll all the way
01:23down to the end of the game we're going to see that towards the end when the game is completed
01:29we're adding a new button and that button in the end of the game creates an event that calls our
01:35on start again which starts the cycle all over again so this is a perfect place to put our ad
01:40because then in the end of the game when the user would click to ask to play another game that
01:44would get another ad all right so then the first step that we want to do right here is we want to
01:50stop that start because we don't really want to start our game in that scenario right
01:56what we want to do is we want to trigger our ad and to do that i'm just going to call the
02:01our moochie media our hope that's how it's pronounced i shouldn't say it so many times
02:08because then someone's going to tell me that it's not the way you pronounce it
02:12oh and i see that in this one i for even though we did preload it we imported it i must have deleted
02:19it by mistake so let's just get that back in there for a second there we go so we got our moochie ad
02:30and that's the really the only item that we really need to start really tinkering here
02:36so what i would want to do is basically i'm going to call moochie ad i'm going to show ad
02:40and there's you're going to see that there are those three now that they have a few names there
02:44but it's because it's deprecated names it's really just these three ads which are right now
02:50we're going to be focused on show inter level ad show inter level ad show click away ad
02:59and then we have the show pregame ad now the preloader ad and the time ad are two
03:04just deprecated methods that are still there just to support earlier users of their ad
03:10application which is basically just calls those three so the pregame ad and the preloader are
03:18basically the same thing and the show time ad is basically the same thing as interval ad and
03:23that's what we want we want our interval ad and you could see already that our interval ad
03:29requires us to send it an object and we're going to do that and we're going to look at
03:32that object and we're going to see there are three parameters that are we could say that they're
03:36mandatory two that are completely mandatory which are the id of our game because if we want
03:41to get paid we have to give them the id of our game and we already saved that id earlier we saved
03:48it in our game id up on the top let's just find that for a second it was all the way in the
03:54beginning so we had our game id oh let me just move that down to make sure that there we go
04:02so i'm just going to grab the game id and go back into our start
04:07and we gave our game id making sure that when the game will run it should run with the id of
04:12our game of our membership now the second item that we have to send is a resolution now the
04:18default resolution or the resolution that's more that it isn't all of the all of their example is
04:24360 by 240 now if there are a few different resolutions and it really just depends on this
04:38type of ad that you're trying to run really some of them have different sizes and sizes some of
04:43them don't and i would just refer to the documentation if you want to use other sizes there
04:48are some sizes such as 500 by 350 and so on but for now we're just going to focus on this one
04:53size and as we're focusing on this one size first of all if we run our application right now
05:00those are those were the two basic parameters that we had to send but our application won't
05:04run really because it's it can't find the clip which is the third parameter that we really have
05:09to send and the third parameter was that movie clip that we created earlier so i'm just going to
05:15take that movie clip and i'm going to send it to our clip which we called it m we called it
05:20go back to my mc ads i'm going to set my x position now i would love to use the stage
05:25stage with and do that you know the right way but unfortunately when main and first loads it
05:32doesn't really have that information yet although well it it does when we're running it here locally
05:38but it won't later on when we're trying to run it through the preloader because the preloader
05:42first runs it runs our main constructor builds it out and only then it's ready so what we could
05:48do is instead of that instead of setting up in the beginning we could just set it up directly
05:52next to our ad all right so the next step is actually like we said we want to set up our x
05:59and y positions from our mc ads so we're going to go i want to set up is my y coordinate
06:06and my y coordinate i want to set to 65 because i have other items on the stage i don't really
06:12i'm not trying to align it to the stage itself i just want to position it in a place where
06:16makes sense on the stage now if we run the application and we click on the star button
06:22we should see now an ad starting and we'll see that it's fetching the information and our ad
06:29and our ad begins a little bit too noisy for us right now and we can see that our ad begins
06:34and we have only one problem although our ad is running we could skip the ad if we click on it
06:39but what would happen when we skip when we skip our ad the ad will go away but then nothing will
06:43happen the reason nothing is happening is because technically we're not doing anything
06:48when the ad is complete we killed our start method earlier but we want the start to be called as soon
06:55as our ad is complete now to do that there is another property inside of the ad parameters
07:02inside of the show interval level object which expects a method and that method we could override
07:09now that method is called add underscore finished what we could do is then assign it a
07:14different method and it's very similar to the way it was worked in action script too which is a very
07:19very nice way of doing things when you're not working with events so instead of using events
07:25it's called callbacks so this is a callback that will be called when that specific event would
07:30happen when the when the ad finishes although we're not triggering an event instead of triggering
07:35an event we're going to tell it then call start the start method and to do that all I have to do
07:40is just tell it call the start put inside that parameter so when ad finish happens when that
07:45method is called we're overriding it and say instead of calling the ad finished call start
07:51well ad finish will be called but then it would be equal to our start which would then trigger our
07:57start method so let's see after we save this if our ad works and again if we click on our
08:04start button we should be seeing an ad and we have an ad running right now we're going to wait
08:10until we could click on the skip button and we'll see if we could get through and here we go skip ad
08:21and our game has started all right so that's all you have to know about working with show
08:29interval um with the interval ads although there's a few other quite a few other parameters
08:35that we're gonna we're gonna just glance at them in a following video but for now this is all you
08:41really need to know to start running and adding ads into your games and we covered now one of
08:48the ad types and let's move on and look at the next ad type

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!