Skip to content

Commit 565d1cb

Browse files
committed
Moved all the examples/test into one, faster to test and more comprehensive example
1 parent c3b3094 commit 565d1cb

File tree

9 files changed

+79
-274
lines changed

9 files changed

+79
-274
lines changed

examples/appopen/project.xml renamed to examples/admobtest/project.xml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,13 @@
66
<!-- https://developers.google.com/admob/ios/quick-start -->
77
<setenv name="ADMOB_APPID" value="ca-app-pub-3940256099942544~1458002511" if="ios" />
88

9-
<meta title="Extension-Admob Test" package="org.openfl.lime.samples.helloworld" version="1.0.0" company="OpenFL" />
9+
<meta title="Extension-Admob Test" package="org.haxe.extensions.admob" version="1.0.0" company="Home-made Extensions Inc." />
1010

1111
<app main="Main" path="export" file="EATest" />
1212

1313
<source path="source" />
1414

1515
<haxelib name="lime" />
16-
<haxelib name="extension-androidtools" if="android" />
1716
<haxelib name="extension-admob" />
1817

1918
<haxeflag name="-dce" value="full" />

examples/admobtest/source/Main.hx

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
package;
2+
3+
import extension.admob.*;
4+
5+
class Main extends lime.app.Application
6+
{
7+
//these are test ids from here: https://developers.google.com/admob/android/test-ads
8+
private static final APP_OPEN_ID:String = "ca-app-pub-3940256099942544/9257395921";
9+
private static final REWARDED_ID:String = "ca-app-pub-3940256099942544/5224354917";
10+
private static final INTERSTITIAL_ID:String = "ca-app-pub-3940256099942544/1033173712";
11+
private static final ADAPTIVE_BANNER_ID:String = "ca-app-pub-3940256099942544/9214589741";
12+
private static final BANNER_ID:String = "ca-app-pub-3940256099942544/6300978111";
13+
14+
public function onCallback(event:String, message:String)
15+
{
16+
switch(event)
17+
{
18+
case AdmobEvent.INIT_OK:
19+
Admob.setVolume(0.5);
20+
Admob.loadAppOpen(APP_OPEN_ID);
21+
22+
case AdmobEvent.APP_OPEN_LOADED:
23+
Admob.showAppOpen();
24+
25+
case AdmobEvent.APP_OPEN_DISMISSED, AdmobEvent.APP_OPEN_FAILED_TO_LOAD, AdmobEvent.APP_OPEN_FAILED_TO_SHOW:
26+
Admob.loadRewarded(REWARDED_ID);
27+
28+
case AdmobEvent.REWARDED_LOADED:
29+
Admob.showRewarded();
30+
31+
case AdmobEvent.REWARDED_DISMISSED, AdmobEvent.REWARDED_FAILED_TO_LOAD, AdmobEvent.REWARDED_FAILED_TO_SHOW:
32+
Admob.loadInterstitial(INTERSTITIAL_ID);
33+
34+
case AdmobEvent.INTERSTITIAL_LOADED:
35+
Admob.showInterstitial();
36+
37+
case AdmobEvent.INTERSTITIAL_DISMISSED, AdmobEvent.INTERSTITIAL_FAILED_TO_LOAD, AdmobEvent.INTERSTITIAL_FAILED_TO_SHOW:
38+
Admob.showBanner(ADAPTIVE_BANNER_ID);
39+
//Admob.showBanner(BANNER_ID, AdmobBannerSize.BANNER, AdmobBannerAlign.TOP);
40+
41+
case AdmobEvent.APP_OPEN_CLICKED, AdmobEvent.INTERSTITIAL_CLICKED, AdmobEvent.REWARDED_CLICKED, AdmobEvent.BANNER_CLICKED:
42+
trace("DINHEIRO!");
43+
44+
case AdmobEvent.REWARDED_EARNED:
45+
trace("REWARD EARNED");
46+
}
47+
48+
trace(event, message);
49+
}
50+
51+
public override function onWindowCreate():Void
52+
{
53+
Admob.setCallback(onCallback);
54+
Admob.init(true);
55+
}
56+
57+
public override function render(context:lime.graphics.RenderContext):Void
58+
{
59+
switch (context.type)
60+
{
61+
case CAIRO:
62+
context.cairo.setSourceRGB(0.75, 1, 0);
63+
context.cairo.paint();
64+
case CANVAS:
65+
context.canvas2D.fillStyle = '#BFFF00';
66+
context.canvas2D.fillRect(0, 0, window.width, window.height);
67+
case DOM:
68+
context.dom.style.backgroundColor = '#BFFF00';
69+
case FLASH:
70+
context.flash.graphics.beginFill(0xBFFF00);
71+
context.flash.graphics.drawRect(0, 0, window.width, window.height);
72+
case OPENGL | OPENGLES | WEBGL:
73+
context.webgl.clearColor(0.75, 1, 0, 1);
74+
context.webgl.clear(context.webgl.COLOR_BUFFER_BIT);
75+
default:
76+
}
77+
}
78+
}

examples/appopen/source/Main.hx

Lines changed: 0 additions & 52 deletions
This file was deleted.

examples/banner/project.xml

Lines changed: 0 additions & 22 deletions
This file was deleted.

examples/banner/source/Main.hx

Lines changed: 0 additions & 50 deletions
This file was deleted.

examples/interstitial/project.xml

Lines changed: 0 additions & 22 deletions
This file was deleted.

examples/interstitial/source/Main.hx

Lines changed: 0 additions & 52 deletions
This file was deleted.

examples/rewarded/project.xml

Lines changed: 0 additions & 22 deletions
This file was deleted.

examples/rewarded/source/Main.hx

Lines changed: 0 additions & 52 deletions
This file was deleted.

0 commit comments

Comments
 (0)