1

我有phonegap構建問題,admob不顯示...我如何顯示它?PhoneGap Build admob

這是我的JS文件

 <script type="text/javascript" src="cordova.js"></script> 
    <script type="text/javascript" src="js/jquery-2.0.3.min.js"></script> 
    <script type="text/javascript" src="js/createjs-2013.09.25.min.js"></script> 
    <script type="text/javascript" src="js/main.js"></script> 
    <script type="text/javascript" src="phonegap.js"></script> 
    <script type="text/javascript" src="js/sounds.js"></script> 
    <script type="text/javascript" src="js/admob.js"></script> 

這是開始遊戲我的主要功能。

<script> 
      $(document).ready(function(){ 
        var oMain = new CMain({ 
            min_reel_loop:2,   
            reel_delay: 6,    
            time_show_win:2000,  
            time_show_all_wins: 2000, 
            money:3000     
           }); 

        $(oMain).on("game_start", function(evt) { 
          //alert("game_start"); 
        }); 

        $(oMain).on("end_bet", function(evt,iMoney,iBetWin) { 
          //alert("iMoney: "+iMoney + " Win:"+iBetWin); 
        }); 

        $(oMain).on("restart", function(evt) { 
          //alert("restart"); 
        }); 

      }); 
     </script> 
+0

刪除cordova.js或phonegap.js,你不應該既不使用,也只使用其中之一。並添加一個鏈接到你正在使用的插件,其中有很多。 – jcesarmobile 2015-02-06 07:15:34

+0

好吧,我剛剛刪除phonegap.js,但我想在我的主要js功能集成時,開始遊戲節目橫幅。 – wpcard 2015-02-06 10:38:46

+0

鏈接到您正在使用的插件? – jcesarmobile 2015-02-06 10:43:14

回答

1

檢查documentation of the AdMob plugin,更具體地說,你需要這個功能與您的自定義設置創建橫幅:

window.plugins.AdMob.setOptions({ 
publisherId: admobid.banner, 
interstitialAdId: admobid.interstitial, 
bannerAtTop: false, // set to true, to put banner at top 
overlap: false, // set to true, to allow banner overlap webview 
offsetTopBar: false, // set to true to avoid ios7 status bar overlap 
isTesting: false, // receiving test ad 
autoShow: true // auto show interstitial ad when loaded 
}); 

的index.html我的例子鏈接即可使用,並顯示與廣告的具體設置。

+0

oK,但怎麼可以我整合在我的代碼中...我想在開始遊戲時展示橫幅。我下載了示例代碼和工作,但我不知道如何在我的主要js函數中進行集成。感謝 – wpcard 2015-02-06 10:38:03

+0

@wpcard您必須複製,粘貼和編輯相關部分,原始代碼很好評論...我可以'爲你編程遊戲,我只能爲你提供參考,指出你在正確的方向,對不起。 – andreszs 2015-02-06 13:01:36

0

迴應您的評論有關如何在遊戲開始時顯示廣告,並在這裏使用插件:https://github.com/appfeel/admob-google-cordova你應該這樣做:

function onDeviceReady() { 
    document.removeEventListener('deviceready', onDeviceReady, false); 

    // Set AdMobAds options: 
    admob.setOptions({ 
    publisherId:   "ca-app-pub-XXXXXXXXXXXXXXXX/BBBBBBBBBB", // Required 
    interstitialAdId:  "ca-app-pub-XXXXXXXXXXXXXXXX/IIIIIIIIII", // Optional 
    }); 

    // Start showing banners (atomatic when autoShowBanner is set to true) 
    admob.createBannerView(); 
} 

document.addEventListener("deviceready", onDeviceReady, false);