Back to project page ssniper-andengine.
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.
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; } }