Construct 2 and Admob Ads


#1

Anyone know how to get Admob Ads (or any other type of Ads that work better) when using Construct 2 by scirra?


#2

You can do this using the Cocoon Construct2 plugin. Once you have integrated the CocoonAds object and events in you Construct2 project you just have to go to the Cocoon Cloud, install a Cocoon Plugin for Ads in your project and compile a Developer App or a final project.

We should have some tutorials describing all this. I hope we have some time soon to do this.


#3

Hi imanolm1, Thanks! I have the Cocoon plugin in my app and installed the Cocoon Plugin in my project, but not sure if I am integrating it correctly. All I did was “Show banner ad” on Start of Layout in my Construct project? Where do I insert my Ad ID? Or do I have to use AdmobAds object in Construct as well?


#4

You have to configure you IDs in the Cocoon Ads object otherwise it won’t work.

@andy_reitberger has made a template to show how to integrate several Cocoon services in Construct2.
Take a look at it here: [Construct 2] How to use AtomicPlugins (Code Example)

Kudos to @andy_reitberger for sharing this with the Cocoon users!


#5

None of these options work for me :frowning: Anyone able to successfully get ads to show?


#6

Hi @jook00
Ads are working fine on my developer template.
You can download the source code for free here:

You also will find an android demo in that post.

Regards
Andy


#7

I can confirm ads are working fine. I have now updated 4 of my CocoonJS apps to Cocoon.IO and moved each to native admob ads. It’s a beautiful thing.

I do plan on going through this in my video tutorials, but the basic steps are.

Setup your ad on admob and get the Ad Unit ID.

Download and install the latest plugins for Construct 2

Add the Cocoon Ads object to your project.

Click on the CocoonAds object in your projects window. In the properties window, paste in your Ad Unit where it says Banner ID. Leave size on SMART.

In your code LOAD BANNER AD, SET BANNER LAYOUT, and SHOW BANNER AD should be used.

Export as Cordova. Zip up everything.

In Cocoon.IO, drag in your zip and edit the settings for the project. Make sure to choose Canvas+
For plugins make sure to install cocoon-plugin-ads-android-admob, save.

That’s it. Should work.


#8

I get an Javascript error, even with the demo. ATPAds_plugins.js

Am I missing an installation of ATPAds or something? What is it?


#9

When do you get the error?

Are you talking about previewing the app from C2? If so, you can’t preview. You need to build with Cocoon.io for testing.


#10

Also the ads are only working in the Developer App or in the built android file.
You cannot test the ads in the browser, even if you woudn’t get the javascript error.

Regards


#11

I get the same error when i try to test in browser preview. I know it only works when is compiled but we need to make small changes and is very annoying to remove the plugin everytime i need to test in preview.


#12

If you include the CanvasPlus plugin, then use the Is Canvas + event before calling your ads, it should not give the error. I just tested it.

For example, I can run this and preview will work.

If I just try to put Load Ad Banner in start of layout, I get the error.


#13

Arcad, thanks for the tip on getting around error on preview. Where do I put “Set banner Layout” and “Show the banner ad”? On “On Banner Loaded”?

Do the banners show in Preview or only on device through APK?


#14

You can download our free code examples.

Those files show you a possible way how to use ads (and other functions).

Regards
Andy


#15

Depends on your game. I typically do it ON Start Of Layout of the layout I am showing ads on.

No, preview will not show ads at all. You will need to wait for the compiled APK to test them.


#16

Can I export to Cocoon or only Cordova to get ads working?


#17

Hi @CModProduction

You need to export to Cordova. You find a complete guide here

Regards
Andy


#18

Obrigado meu amigo !


#19

@andy_reitberger
I finally got ads working using your template! Thank you so much for that!

One issue is that my ads are refreshing to new banners every 1-2 seconds. I have it set in Admob to every 30 seconds. Do you know any reason for this?


#20

@andy_reitberger I think I see your response here:

I found the issue.
I submitted a Pull Request on Github.
Till the changes are live, please download the attached plugin and overwrite the existing one in C2.
Thank you!

cocoon_ads.zip