Android Open Source - RollOverSphere---a-simple-libgdx-game Intro Scene Buttons Object






From Project

Back to project page RollOverSphere---a-simple-libgdx-game.

License

The source code is released under:

MIT License

If you think the Android project RollOverSphere---a-simple-libgdx-game listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.igorcrevar.rolloverchuck.objects;
//from  ww  w.j a va  2  s.c om
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.igorcrevar.rolloverchuck.GameManager;
import com.igorcrevar.rolloverchuck.IActivityRequestHandler;
import com.igorcrevar.rolloverchuck.ISceneManager;

public class IntroSceneButtonsObject  {
  // buttons
  private GameButton[] buttons;
  private final GameButton soundButton;
  
  public IntroSceneButtonsObject(final ISceneManager sceneManager, final float initialY) {
    final GameManager gameManager = sceneManager.getGameManager();
    final IActivityRequestHandler activityRequestHandler = sceneManager.getRequestHandler();
    buttons = new GameButton[3];
    
    soundButton = addButton(new GameButton(getTextureForSoundButton(gameManager), 1700, initialY, 120, 120) {
      @Override
      protected void onClick() {
        gameManager.setSoundOn(!gameManager.getIsSoundOn());
        soundButton.changeTexture(getTextureForSoundButton(gameManager));
      }
    });
        
    addButton(new GameButton(getTextureRegion("rate", gameManager), 1700, initialY - 160f, 120, 120) {
      @Override
      protected void onClick() {
        activityRequestHandler.rate();
      }
    });  
    
    /*addButton(new GameButton(getTextureRegion("ach", gameManager), 300, upButtonsY, 200, 200) {
      @Override
      protected void onClick() {
        activityRequestHandler.showAchievements();
      }
    });
    */
    addButton(new GameButton(getTextureRegion("share", gameManager), 1540, initialY - 160f, 120, 120) {
      @Override
      protected void onClick() {
        activityRequestHandler.share();
      }
    });    
  }
  
  private GameButton addButton(GameButton gb) {
    for (int i = 0; i < buttons.length; ++i) {
      if (buttons[i] == null) {
        buttons[i] = gb;
        break;
      }
    }
    
    return gb;
  }
  
  public boolean check(float x, float y) {    
    for (GameButton gb : buttons) {
      if (gb.check(x, y)) {
        return true;
      }
    }
    
    return false;
  }
    
  public void draw(SpriteBatch spriteBatch) {
    for (GameButton gb : buttons) {
      gb.draw(spriteBatch);
    }
  }
  
  private TextureRegion getTextureForSoundButton(GameManager gameManager) {
    if (gameManager.getIsSoundOn()) {
      return getTextureRegion("soundon", gameManager);
    }
    
    return getTextureRegion("soundoff", gameManager);
  }
  
  private TextureRegion getTextureRegion(String name, GameManager gameManager) {
    return gameManager.getTextureAtlas("widgets").findRegion(name);
  }
}




Java Source Code List

com.google.example.games.basegameutils.GameHelperUtils.java
com.google.example.games.basegameutils.GameHelper.java
com.igorcrevar.rolloverchuck.DesktopRunner.java
com.igorcrevar.rolloverchuck.GameConsts.java
com.igorcrevar.rolloverchuck.GameData.java
com.igorcrevar.rolloverchuck.GameListener.java
com.igorcrevar.rolloverchuck.GameManager.java
com.igorcrevar.rolloverchuck.GameType.java
com.igorcrevar.rolloverchuck.IActivityRequestHandler.java
com.igorcrevar.rolloverchuck.ISceneManager.java
com.igorcrevar.rolloverchuck.IScene.java
com.igorcrevar.rolloverchuck.mesh.CubeMeshWithNormals.java
com.igorcrevar.rolloverchuck.mesh.CubeMesh.java
com.igorcrevar.rolloverchuck.mesh.FieldMesh.java
com.igorcrevar.rolloverchuck.mesh.IMesh.java
com.igorcrevar.rolloverchuck.mesh.SphereMesh.java
com.igorcrevar.rolloverchuck.objects.BoxObject.java
com.igorcrevar.rolloverchuck.objects.ChuckObject.java
com.igorcrevar.rolloverchuck.objects.ChuckSpriteObject.java
com.igorcrevar.rolloverchuck.objects.EndGameButtonsObject.java
com.igorcrevar.rolloverchuck.objects.FieldObject.java
com.igorcrevar.rolloverchuck.objects.GameButton.java
com.igorcrevar.rolloverchuck.objects.IntroSceneButtonsObject.java
com.igorcrevar.rolloverchuck.objects.MainWallObject.java
com.igorcrevar.rolloverchuck.objects.StarsObject.java
com.igorcrevar.rolloverchuck.objects.TextButton.java
com.igorcrevar.rolloverchuck.objects.TrailObject.java
com.igorcrevar.rolloverchuck.objects.boxes.BoxManager.java
com.igorcrevar.rolloverchuck.objects.boxes.BoxRegionManager.java
com.igorcrevar.rolloverchuck.objects.boxes.BoxRegion.java
com.igorcrevar.rolloverchuck.objects.boxes.BoxTypeFactory.java
com.igorcrevar.rolloverchuck.objects.boxes.IBoxRegion.java
com.igorcrevar.rolloverchuck.objects.boxes.IBoxType.java
com.igorcrevar.rolloverchuck.physics.CollisionSolver.java
com.igorcrevar.rolloverchuck.physics.ICollisionIterationHandler.java
com.igorcrevar.rolloverchuck.physics.SphereMoving.java
com.igorcrevar.rolloverchuck.points.PlayerPoint.java
com.igorcrevar.rolloverchuck.points.PointsManager.java
com.igorcrevar.rolloverchuck.scenes.GameLoadingScene.java
com.igorcrevar.rolloverchuck.scenes.GameScene.java
com.igorcrevar.rolloverchuck.scenes.IntroScene.java
com.igorcrevar.rolloverchuck.scenes.GameMode.ArcadeGameMode.java
com.igorcrevar.rolloverchuck.scenes.GameMode.IGameMode.java
com.igorcrevar.rolloverchuck.scenes.GameMode.StressFreeGameMode.java
com.igorcrevar.rolloverchuck.utils.CollisionHelper.java
com.igorcrevar.rolloverchuck.utils.GameHelper.java
com.igorcrevar.rolloverchuck.utils.IMyFontDrawerFont.java
com.igorcrevar.rolloverchuck.utils.Mathf.java
com.igorcrevar.rolloverchuck.utils.MyFontDrawerBatch.java
com.igorcrevar.rolloverchuck.utils.MyFontDrawerDefaultFont.java
com.igorcrevar.rolloverchuck.utils.MyFontDrawer.java
com.igorcrevar.rolloverchuck.utils.ShaderAssetLoader.java
com.wayilookatgames.rolloverball.MainActivity.java