Android Open Source - ssniper-andengine Main Menu Scene






From Project

Back to project page ssniper-andengine.

License

The source code is released under:

Apache License

If you think the Android project ssniper-andengine 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.cladophora.ssniper.scene;
/*  www  .  jav a 2 s.c  om*/
import com.cladophora.ssniper.BaseActivity;
import com.cladophora.ssniper.R;
import org.andengine.entity.modifier.MoveXModifier;
import org.andengine.entity.scene.background.Background;
import org.andengine.entity.scene.menu.MenuScene;
import org.andengine.entity.scene.menu.MenuScene.IOnMenuItemClickListener;
import org.andengine.entity.scene.menu.item.IMenuItem;
import org.andengine.entity.scene.menu.item.TextMenuItem;
import org.andengine.entity.text.Text;
import org.andengine.util.color.Color;

public class MainMenuScene extends MenuScene implements IOnMenuItemClickListener {
    BaseActivity activity;
  final int MENU_START = 0;
    final int MENU_INSTRUCTIONS = 1;

  public MainMenuScene() {
    activity = BaseActivity.getSharedInstance();

    setBackground(new Background(Color.WHITE));

        final float height = BaseActivity.CAMERA_HEIGHT;
        final float width = BaseActivity.CAMERA_WIDTH;

        Text title1 = new Text(0, 0, BaseActivity.mNotoSansFont, activity.getString(R.string.app_name) + " ", activity.getVertexBufferObjectManager());
        title1.setPosition(-title1.getWidth(), height / 4);
        attachChild(title1);
        title1.registerEntityModifier(new MoveXModifier(1, title1.getX(), width / 2 - title1.getWidth()));

    IMenuItem startButton = new TextMenuItem(MENU_START, BaseActivity.mNotoSansFont, activity.getString(R.string.start), activity.getVertexBufferObjectManager());
        IMenuItem instructionsButton = new TextMenuItem(MENU_INSTRUCTIONS, BaseActivity.mNotoSansFont, activity.getString(R.string.instructions), activity.getVertexBufferObjectManager());

        title1.setColor(Color.BLACK);
        startButton.setColor(Color.BLACK);
        instructionsButton.setColor(Color.BLACK);

    startButton.setPosition(width / 2 - startButton.getWidth() / 2, height / 2 - startButton.getHeight() / 2);
        instructionsButton.setPosition(width / 2 - instructionsButton.getWidth() / 2, height / 2 + instructionsButton.getHeight() / 2);

    addMenuItem(startButton);
        addMenuItem(instructionsButton);

    setOnMenuItemClickListener(this);
  }

  @Override
  public boolean onMenuItemClicked(MenuScene arg0, IMenuItem arg1, float arg2, float arg3) {
    switch (arg1.getID()) {
            case MENU_START:
                activity.setCurrentScene(new GameScene());
                return true;
            case MENU_INSTRUCTIONS:
                //Log.v("MainMenuScene.onMenuItemClicked()", "Hover the S Pen over an enemy to aim. Pull the pen away then tap anywhere to fire.");
                return true;
            default:
                break;
    }
    return false;
  }

}




Java Source Code List

com.cladophora.ssniper.BaseActivity.java
com.cladophora.ssniper.DeviceUtil.java
com.cladophora.ssniper.EnemyPool.java
com.cladophora.ssniper.GameEffects.java
com.cladophora.ssniper.GameEvents.java
com.cladophora.ssniper.GameLoopUpdateHandler.java
com.cladophora.ssniper.GameUtil.java
com.cladophora.ssniper.HUDManager.java
com.cladophora.ssniper.HoverListener.java
com.cladophora.ssniper.ItemPool.java
com.cladophora.ssniper.LevelLoader.java
com.cladophora.ssniper.PlantPool.java
com.cladophora.ssniper.SPenHoverView.java
com.cladophora.ssniper.ScopeEngine.java
com.cladophora.ssniper.SoundManager.java
com.cladophora.ssniper.SpriteManager.java
com.cladophora.ssniper.andengine.IRandomTimerCallBack.java
com.cladophora.ssniper.andengine.RandomTimerHandler.java
com.cladophora.ssniper.entity.EnemyLayer.java
com.cladophora.ssniper.entity.Enemy.java
com.cladophora.ssniper.entity.ItemLayer.java
com.cladophora.ssniper.entity.Item.java
com.cladophora.ssniper.entity.PlantLayer.java
com.cladophora.ssniper.entity.Plant.java
com.cladophora.ssniper.entity.Reticle.java
com.cladophora.ssniper.entity.Rifle.java
com.cladophora.ssniper.entity.SPen.java
com.cladophora.ssniper.scene.GameScene.java
com.cladophora.ssniper.scene.InstructionScene.java
com.cladophora.ssniper.scene.IntroScene.java
com.cladophora.ssniper.scene.MainMenuScene.java
com.cladophora.ssniper.scene.PauseScene.java
com.cladophora.ssniper.scene.ResultScene.java
com.cladophora.ssniper.scene.ShopScene.java
com.cladophora.ssniper.scene.SplashScene.java
com.cladophora.ssniper.scene.SurvivorIntroScene.java
com.cladophora.ssniper.scene.SurvivorScene.java
com.cladophora.ssniper.scene.TutorialScene.java
com.cladophora.ssniper.scene.WeaponInfoScene.java