Skip to content
This repository has been archived by the owner on Jun 26, 2024. It is now read-only.

Tomobodo/extension-dfp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

exension-dfp

extension to use dfp in your game

Use

First include the following extension in your project.xml : google-play-service. You can find it here.

<haxelib name="google-play-service" if="android"/>

Then include the extension.

<haxelib name="dfp" />

Sample

import org.extension.dfp.DFP;
import org.extension.dfp.AdPosition;
import org.extension.dfp.AdSize;

import openfl.events.MouseEvent;
import openfl.display.Sprite;

class MyGame extends Sprite {
    
    public function new(){
        super();
        
        DFP.initAd("/45698/YOUR_DFP_TAG", AdPosition.CENTER, AdPosition.BOTTOM, AdSize.BANNER);
        DFP.showAd();
        
        var btnTest = new Sprite();
        btnTest.graphics.beginFill(0x0000ff);
        btnTest.graphics.drawRect(0,0,200,100);
        addChild(btnTest);
        
        btnTest.addEventListener(MouseEvent.CLICK, onClick);
    }
    
    function onClick(e : Event){
        DFP.setInterstitialListeners(this, "onInterstitialLoaded", "onInterstitialError", "onInterstitialClosed");
        DFP.initInterstitial("/45698/YOUR_DFP_INTERSTIAL");
    }
    
    function onInterstitialClosed() {
		trace("adClosed");
	}
	
	function onInterstitialError(errorCode : Int) {
		trace(errorCode);
	}
	
	function onInterstitialLoaded() {
		trace("adLoaded" );
		DFP.showInterstitial();
	}
    
}

About

extension to use dfp in your game

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published