Android Open Source - ssniper-andengine Intro 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;
//from  w w  w  .j  av a2  s.  c  om
import com.cladophora.ssniper.BaseActivity;
import com.cladophora.ssniper.R;
import com.cladophora.ssniper.entity.EnemyLayer;
import com.cladophora.ssniper.entity.ItemLayer;
import com.cladophora.ssniper.entity.Reticle;
import org.andengine.engine.camera.Camera;
import org.andengine.engine.camera.hud.HUD;
import org.andengine.entity.IEntity;
import org.andengine.entity.modifier.DelayModifier;
import org.andengine.entity.primitive.Rectangle;
import org.andengine.entity.scene.CameraScene;
import org.andengine.entity.scene.IOnSceneTouchListener;
import org.andengine.entity.scene.Scene;
import org.andengine.entity.text.AutoWrap;
import org.andengine.entity.text.Text;
import org.andengine.entity.text.TextOptions;
import org.andengine.input.touch.TouchEvent;
import org.andengine.opengl.vbo.VertexBufferObjectManager;
import org.andengine.util.HorizontalAlign;
import org.andengine.util.color.Color;

public class IntroScene extends CameraScene implements IOnSceneTouchListener {

    private static boolean done = false;

    public IntroScene(Camera mCamera) {
    super(mCamera);
        done = false;
        setBackgroundEnabled(false);
    setOnSceneTouchListener(this);
        Reticle.hide();
        EnemyLayer.hide();
        ItemLayer.hide();
        GameScene.inGame = false;
        GameScene.pause();
        loadResources();
    }

    private void loadResources() {
        final HUD introHUD = new HUD();
        final VertexBufferObjectManager vbom = BaseActivity.getSharedInstance().getVertexBufferObjectManager();
        final BaseActivity activity = BaseActivity.getSharedInstance();

        String hintMsg;

        int hintID = BaseActivity.r.nextInt(5);
        switch(hintID) {
            case 0:
                hintMsg = activity.getString(R.string.difficultymsg0);
                break;
            case 1:
                hintMsg = activity.getString(R.string.difficultymsg1);
                break;
            case 2:
                hintMsg = activity.getString(R.string.gameplaytext0);
                break;
            case 3:
                hintMsg = activity.getString(R.string.gameplaytext1);
                break;
            case 4:
                hintMsg = activity.getString(R.string.gameplaytext2);
                break;
            default:
                hintMsg = "";
                break;
        }

        String introMsg = activity.getString(R.string.level) + " " + String.valueOf(GameScene.levelID + 1) + " / " + String.valueOf(GameScene.FINAL_LEVEL);

        float wrapWidth = BaseActivity.CAMERA_WIDTH - (BaseActivity.SCOPE_SIZE + 40);
        final Text introText = new Text(0,0,BaseActivity.mNotoSansFont,introMsg,1000,new TextOptions(AutoWrap.WORDS, wrapWidth, HorizontalAlign.LEFT), vbom);
        final Text introText2 = new Text(0,0,BaseActivity.mNotoSansFont,hintMsg,1000,new TextOptions(AutoWrap.WORDS, wrapWidth, HorizontalAlign.LEFT), vbom);
        introText.setColor(Color.BLACK);
        introText2.setColor(Color.BLACK);
        introText.setPosition(20, 20);
        introText2.setPosition(20, introText.getHeight() + 40);

        final Rectangle bg = new Rectangle(BaseActivity.SCOPE_SIZE,(BaseActivity.CAMERA_HEIGHT / 2) - (introText.getHeight() + introText2.getHeight() + 60)/2, introText2.getWidth() + 40,introText.getHeight() + introText2.getHeight() + 60,BaseActivity.getSharedInstance().getVertexBufferObjectManager());
        bg.setColor(Color.WHITE);
        bg.setAlpha(GameScene.P_ALPHA);

        bg.detachSelf();
        introText.detachSelf();
        introText2.detachSelf();

        bg.setVisible(true);
        introHUD.attachChild(bg);
        bg.attachChild(introText);
        bg.attachChild(introText2);

        mCamera.setHUD(introHUD);

        introText.registerEntityModifier(new DelayModifier(0.5f) {
            @Override
            protected void onModifierFinished(IEntity pItem) {
                done = true;
            }
        });
    }

    @Override
  public boolean onSceneTouchEvent(Scene arg0, TouchEvent arg1) {
        if (!done) { return true; }
        GameScene.inGame = false;
        GameScene.tStart = BaseActivity.getSharedInstance().getEngine().getSecondsElapsedTotal();
        GameScene.resume();
        GameScene.getSharedInstance().clearChildScene();
        GameScene.getSharedInstance().setChildScene(new ShopScene(BaseActivity.mCamera));
        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