Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (489)
Games in Android Showcase (112)
games submitted by our members
Games in WIP (553)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
  JavaGaming.org - Pastebin



Author: imbrendino (posted 2014-05-03 16:35:04, viewed 102 times)

1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   23   24   25   26   27   28   29   30   31   32   33   34   35   36   37   38   39   40   41   42   43   44   45   46   47   48   49   50   51   52   53   54   55   56   57   58   59   60   61   62   63   64   65   66   67   68   69   70   71   72   73   74   75   76   77   78   79   80   81   82   83   84   85   86   87   88   89   90   91   92   93   94   95   96   97   98   99   100   101   102   103   104   105   106   107   108   109   110   111   112   113   114   115   116   117   118   119   120   121   122   123   124   125   126   127   128   129   130   131   132   133   134   135   136   137   138   139   140   141   142   143   144   145   146   147   148   149   150   151   152   153   154   155   156   157   158   159   160   161   162   163   164   165   166   167   168   169   170   171   172   173   174   175   176   177   178   179   180   181   182   183   184   185   186   187   188   189   190   191   192   193   194   195   196   197   198   199   200   201   202   203   204   205   206   207   208   209   210   211   212   213   214   215   216   217   218   219   220   221   222   223   224   225   226   227   228   229   230   231   232   233   234   235   236   237   238   239   240   241   242   243   244   245   246   247   248   249   250   251   252   253   254   255   256   257   258   259   260   261   262   263   264   265   266   267   268   269   270   271   272   273   274   275   276   277   278   279   280   281   282   283   284   285   286   287   288   289   290   291   292   293   294   295   296   297   298   299   300   301   302   303   304   305   306   307   308   309   310   311   312   313   314   315   316   317   318   319   320   321   322   323   324   325   326   327   328   329   330   331   332   333   334   335   336   337   338   339   340   341   342   343   344   345   346   347   348   349   350   351   352   353   354   355   356   357   358   359   360   361   362  
package com.me.jumper;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.RelativeLayout;

import com.badlogic.gdx.backends.android.AndroidApplication;
import com.badlogic.gdx.backends.android.AndroidApplicationConfiguration;
import com.me.jumper.gameservices.ActionResolver;
import com.chartboost.sdk.*;
import com.chartboost.sdk.Chartboost.CBAgeGateConfirmation;
import com.chartboost.sdk.Model.CBError.CBClickError;
import com.chartboost.sdk.Model.CBError.CBImpressionError;
import com.jirbo.adcolony.*;
import com.google.android.gms.ads.*;
import com.google.android.gms.games.Games;
import com.google.example.games.basegameutils.GameHelper;
import com.google.example.games.basegameutils.GameHelper.GameHelperListener;



public class MainActivity extends AndroidApplication implements GameHelperListener, ActionResolver{

   private GameHelper mHelper;
   
   private Jumper jumper;
   private Chartboost cb;
   private AdColonyVideoAd ad;
   private AdView adView;
   
   
   public MainActivity(){
      
   }
   
   @Override
    public void onCreate(Bundle savedInstanceState) {
      
      
      mHelper= new GameHelper(this, GameHelper.CLIENT_ALL);
      mHelper.enableDebugLog(true);
        super.onCreate(savedInstanceState);
        
        
     // Create the layout
        RelativeLayout layout = new RelativeLayout(this);

        // Do the stuff that initialize() would do for you
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, 
                        WindowManager.LayoutParams.FLAG_FULLSCREEN);
        getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
        

        // Create the libgdx View
        AndroidApplicationConfiguration cfg = new AndroidApplicationConfiguration();
        cfg.useGL20 = true;
        jumper = new Jumper(this);
        RelativeLayout.LayoutParams gameViewParams =
                new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, 
                        RelativeLayout.LayoutParams.WRAP_CONTENT);
        gameViewParams.topMargin = AdSize.BANNER.getHeight();
        System.out.println("ciaoooooooooo1");
        mHelper.setup(this);
        System.out.println("ciaoooooooooo2");
        View gameView = initializeForView(jumper, cfg);

        // Create and setup the AdMob view
        adView = new AdView(this);
        adView.setAdUnitId("xxxxxxxxxxxxxx");
        adView.setAdSize(AdSize.BANNER); // Put in your secret key here
        adView.loadAd(new AdRequest.Builder().build());

        // Add the libgdx view
        layout.addView(gameView,gameViewParams);

        // Add the AdMob view
        RelativeLayout.LayoutParams adParams = 
                new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, 
                                RelativeLayout.LayoutParams.WRAP_CONTENT);
        adParams.addRule(RelativeLayout.ALIGN_PARENT_TOP);
        adParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
        

        layout.addView(adView, adParams);
     
        
        
        
        
       
        
       
     // Configure Chartboost

        
        this.cb = Chartboost.sharedChartboost();
        String appId = "xxxxxxxxxxxxx";
        String appSignature = "xxxxxxxxxxx";
        CBPreferences.getInstance().setImpressionsUseActivities(true);
        this.cb.onCreate(this, appId, appSignature, this.chartBoostDelegate);
        
        AdColony.configure(this, "version:3.0,store:google", "xxxxxxx", "xxxxxxxxx");
        ad = new AdColonyVideoAd();
        
        
        
        
        
     // Hook it all up
        setContentView(layout);
        
        
    }
   
   @Override
   public void onStart(){
      super.onStart();

      mHelper.onStart(this);
      this.cb.onStart(this);

       // Notify the beginning of a user session. Must not be dependent on user actions or any prior network requests.
       this.cb.startSession();
      

       // Show an interstitial
       this.cb.showInterstitial(); 
       
       
       
       
       
   
      
          
       
      
       
   }

   @Override
   public void onStop(){
      super.onStop();
      mHelper.onStop();
      
      
   }
   
   
   @Override
   public void onActivityResult(int request, int response, Intent data) {
      super.onActivityResult(request, response, data);
       mHelper.onActivityResult(request, response, data);
   }

   @Override
   public boolean getSignedInGPGS() {
      return mHelper.isSignedIn();
   }

   @Override
   public void loginGPGS() {
      try {
         runOnUiThread(new Runnable(){
            public void run() {
               mHelper.beginUserInitiatedSignIn();
            }
         });
      } catch (final Exception ex) {
      }
   }

   @Override
   public void submitScoreGPGS(int score) {
      Games.Leaderboards.submitScore(mHelper.getApiClient(),"xxxxxxx", score);
   }
   
   @Override
   public void unlockAchievementGPGS(String achievementId) {
      Games.Achievements.unlock(mHelper.getApiClient(), achievementId);
   }
   
   @Override
   public void getLeaderboardGPGS() {
      startActivityForResult(Games.Leaderboards.getLeaderboardIntent(mHelper.getApiClient(), "xxxxxxxxxxx"), 100);
   }

   @Override
   public void getAchievementsGPGS() {
      startActivityForResult(Games.Achievements.getAchievementsIntent(mHelper.getApiClient()), 101);
   }
   
   @Override
   public void onSignInFailed() {
      System.out.println("e ke cazzzz");
   }

   @Override
   public void onSignInSucceeded() {
      System.out.println("e ke cazzzz due volte");
   }
   
   
   @Override
   protected void onDestroy() {
       super.onDestroy();
       adView.destroy();
       this.cb.onDestroy(this);
      
   }

   @Override
   public void onBackPressed() {

       // If an interstitial is on screen, close it. Otherwise continue as normal.
       if (this.cb.onBackPressed())
           return;
       else
           super.onBackPressed();
   }
   
   
   private ChartboostDelegate chartBoostDelegate = new ChartboostDelegate() {

      @Override
      public void didCacheInterstitial(String arg0) {
         // TODO Auto-generated method stub
         
      }

      @Override
      public void didCacheMoreApps() {
         // TODO Auto-generated method stub
         
      }

      @Override
      public void didClickInterstitial(String arg0) {
         // TODO Auto-generated method stub
         
      }

      @Override
      public void didClickMoreApps() {
         // TODO Auto-generated method stub
         
      }

      @Override
      public void didCloseInterstitial(String arg0) {
         // TODO Auto-generated method stub
         
      }

      @Override
      public void didCloseMoreApps() {
         // TODO Auto-generated method stub
         
      }

      @Override
      public void didDismissInterstitial(String arg0) {
         // TODO Auto-generated method stub
         
      }

      @Override
      public void didDismissMoreApps() {
         // TODO Auto-generated method stub
         
      }

      @Override
      public void didFailToLoadInterstitial(String arg0,
            CBImpressionError arg1) {
         // TODO Auto-generated method stub
         
      }

      @Override
      public void didFailToLoadMoreApps(CBImpressionError arg0) {
         // TODO Auto-generated method stub
         
      }

      @Override
      public void didFailToRecordClick(String arg0, CBClickError arg1) {
         // TODO Auto-generated method stub
         
      }

      @Override
      public void didShowInterstitial(String arg0) {
         // TODO Auto-generated method stub
         
      }

      @Override
      public void didShowMoreApps() {
         // TODO Auto-generated method stub
         
      }

      @Override
      public boolean shouldDisplayInterstitial(String arg0) {
         if(!jumper.mostra)
            return false;
         else{
            ad.show();
            return true;
         }
         
      }

      @Override
      public boolean shouldDisplayLoadingViewForMoreApps() {
         // TODO Auto-generated method stub
         return true;
      }

      @Override
      public boolean shouldDisplayMoreApps() {
         // TODO Auto-generated method stub
         return true;
      }

      @Override
      public boolean shouldPauseClickForConfirmation(
            CBAgeGateConfirmation arg0) {
         // TODO Auto-generated method stub
         return true;
      }

      @Override
      public boolean shouldRequestInterstitial(String arg0) {
         // TODO Auto-generated method stub
         return true;
      }

      @Override
      public boolean shouldRequestInterstitialsInFirstSession() {
         // TODO Auto-generated method stub
         return true;
      }

      @Override
      public boolean shouldRequestMoreApps() {
         // TODO Auto-generated method stub
         return true;
      }
      
   };


   
   

}





Dump your java code here :



Special syntax:
  • To highlight a line (yellow background), prefix it with '@@'
  • To indicate that a line should be removed (red background), prefix it with '-'
  • To indicate that a line should be added (green background), prefix it with '+'
  • To post multiple snippets, seperate them by '~~~~'
  EOF
 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

TehJavaDev (18 views)
2014-08-28 18:26:30

CopyableCougar4 (26 views)
2014-08-22 19:31:30

atombrot (39 views)
2014-08-19 09:29:53

Tekkerue (36 views)
2014-08-16 06:45:27

Tekkerue (33 views)
2014-08-16 06:22:17

Tekkerue (22 views)
2014-08-16 06:20:21

Tekkerue (33 views)
2014-08-16 06:12:11

Rayexar (70 views)
2014-08-11 02:49:23

BurntPizza (47 views)
2014-08-09 21:09:32

BurntPizza (37 views)
2014-08-08 02:01:56
List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!