Android Open Source - ssniper-andengine Survivor 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 .  ja  va 2  s  .c  o m
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 SurvivorIntroScene extends CameraScene implements IOnSceneTouchListener {

    private static boolean done = false;

    public SurvivorIntroScene(Camera mCamera) {
    super(mCamera);
        done = false;
        SurvivorScene.inSurvivorMode = true;
        setBackgroundEnabled(false);
    setOnSceneTouchListener(this);
        Reticle.hide();
        EnemyLayer.purge();
        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 = activity.getString(R.string.survivor1);
        String hintMsg2 = activity.getString(R.string.survivor2);
        String introMsg = activity.getString(R.string.survivor0);

        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);
        final Text introText3 = new Text(0,0,BaseActivity.mNotoSansFont,hintMsg2,1000,new TextOptions(AutoWrap.WORDS, wrapWidth, HorizontalAlign.LEFT), vbom);
        introText.setColor(Color.BLACK);
        introText2.setColor(Color.BLACK);
        introText3.setColor(Color.BLACK);
        introText.setPosition(20, 20);
        introText2.setPosition(20, introText.getY() + introText.getHeight() + 20);
        introText3.setPosition(20, introText2.getY() + introText2.getHeight() + 20);

        float textWidth;
        if (introText2.getWidth() > introText3.getWidth()) {
            textWidth = introText2.getWidth();
        } else {textWidth = introText3.getWidth();}

        float textHeight = introText.getHeight() + introText2.getHeight() + introText3.getHeight() + 80;

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

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

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

        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