Back to project page BlockHopper.
The source code is released under:
Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION...
If you think the Android project BlockHopper 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.example.blockhopper; //from ww w. j a v a2s. c om import org.andengine.engine.Engine; import org.andengine.engine.camera.Camera; import org.andengine.entity.scene.Scene; import org.andengine.entity.sprite.Sprite; import org.andengine.input.touch.TouchEvent; import org.andengine.opengl.font.Font; import org.andengine.opengl.font.FontFactory; import org.andengine.opengl.texture.atlas.bitmap.BitmapTextureAtlas; import org.andengine.opengl.texture.atlas.bitmap.BitmapTextureAtlasTextureRegionFactory; import org.andengine.opengl.texture.region.ITextureRegion; import org.andengine.opengl.vbo.VertexBufferObjectManager; import org.andengine.ui.activity.BaseGameActivity; import android.graphics.Typeface; public class MenuScene extends Scene /*implements IOnAreaTouchListener*/ { private Scene menuScene = new Scene(); private Camera camera; private BaseGameActivity activity; private Engine eng; private BitmapTextureAtlas normalTexture; private ITextureRegion normalTextureRegion; private GameScene gScene; public MenuScene(BaseGameActivity act, Engine eng, Camera cam){ this.activity = act; //passes this class the game engine, BaseGameactivty, and the camera objects this.eng = eng; this.camera = cam; } public void loadMenuScene() { gScene = new GameScene(this.activity,this.eng,this.camera); //creating gamescene obj that will be called from this class BitmapTextureAtlasTextureRegionFactory.setAssetBasePath("gfx/"); normalTexture = new BitmapTextureAtlas(this.activity.getTextureManager(),128, 32); //creating texture for the play button normalTextureRegion = BitmapTextureAtlasTextureRegionFactory.createFromAsset(normalTexture, this.activity, "play.png", 0, 0); normalTexture.load(); } public void createMenuScene(){ Font font = FontFactory.create(eng.getFontManager(), eng.getTextureManager(),128, 64, Typeface.create(Typeface.DEFAULT, Typeface.BOLD), 16); font.load(); VertexBufferObjectManager vbom = eng.getVertexBufferObjectManager(); Sprite button = new Sprite(camera.getCenterX() - 64, camera.getCenterY() - 16, normalTextureRegion,vbom){ @Override public boolean onAreaTouched(final TouchEvent pSceneTouchEvent, final float pTouchAreaLocalX, final float pTouchAreaLocalY) { gScene.loadGameScene(); //loading, creating, and setting the game scene gScene.createGameScene(); eng.setScene(gScene.getScene()); return true; } }; menuScene.attachChild(button); //attatching button and enabling touch menuScene.setTouchAreaBindingOnActionDownEnabled(true); menuScene.registerTouchArea(button); } public Scene getScene(){ //returns the scene return menuScene; } }