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 . 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; } }