Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.slidefuse.MinecraftShootout;
- import org.anddev.andengine.engine.Engine;
- import org.anddev.andengine.engine.camera.Camera;
- import org.anddev.andengine.engine.options.EngineOptions;
- import org.anddev.andengine.engine.options.EngineOptions.ScreenOrientation;
- import org.anddev.andengine.engine.options.resolutionpolicy.RatioResolutionPolicy;
- import org.anddev.andengine.entity.scene.Scene;
- import org.anddev.andengine.entity.scene.background.ColorBackground;
- import org.anddev.andengine.entity.sprite.Sprite;
- import org.anddev.andengine.entity.util.FPSLogger;
- import org.anddev.andengine.opengl.texture.Texture;
- import org.anddev.andengine.opengl.texture.TextureOptions;
- import org.anddev.andengine.opengl.texture.region.TextureRegion;
- import org.anddev.andengine.opengl.texture.region.TextureRegionFactory;
- import org.anddev.andengine.ui.activity.BaseGameActivity;
- public class MinecraftShootout extends BaseGameActivity {
- // ===========================================================
- // Constants
- // ===========================================================
- private static final int CAMERA_WIDTH = 320;
- private static final int CAMERA_HEIGHT = 480;
- // ===========================================================
- // Fields
- // ===========================================================
- private Camera mCamera;
- // ===========================================================
- // Constructors
- // ===========================================================
- // ===========================================================
- // Getter & Setter
- // ===========================================================
- // ===========================================================
- // Methods for/from SuperClass/Interfaces
- // ===========================================================
- @Override
- public Engine onLoadEngine() {
- this.mCamera = new Camera(0, 0, CAMERA_WIDTH, CAMERA_HEIGHT);
- return new Engine(new EngineOptions(true, ScreenOrientation.PORTRAIT, new RatioResolutionPolicy(CAMERA_WIDTH, CAMERA_HEIGHT), this.mCamera));
- }
- @Override
- public void onLoadResources() {
- /*this.mTexture = new Texture(256, 256, TextureOptions.BILINEAR_PREMULTIPLYALPHA);
- this.mFaceTextureRegion = TextureRegionFactory.createFromAsset(this.mTexture, this, "default.png", 0, 0);
- this.backgroundText = new Texture(320, 480, TextureOptions.BILINEAR_PREMULTIPLYALPHA);
- this.backgroundTextReg = TextureRegionFactory.createFromAsset(this.backgroundText, this, "background.png", 0, 0);
- this.mEngine.getTextureManager().loadTexture(this.mTexture);
- this.mEngine.getTextureManager().loadTexture(this.backgroundText);*/
- }
- @Override
- public Scene onLoadScene() {
- this.mEngine.registerUpdateHandler(new FPSLogger());
- final Scene scene = new Scene();
- scene.setBackground(getBackgroundColor(255, 0, 0));
- /* Add Background */
- //final Sprite background = new Sprite(0, 0, this.backgroundTextReg);
- /* Calculate the coordinates for the face, so its centered on the camera.
- final int centerX = (CAMERA_WIDTH - this.mFaceTextureRegion.getWidth()) / 2;
- final int centerY = (CAMERA_HEIGHT - this.mFaceTextureRegion.getHeight()) / 2;
- /* Create the face and add it to the scene.
- final Sprite face = new Sprite(centerX, centerY, this.mFaceTextureRegion) {
- @Override
- public boolean onAreaTouched(TouchEvent e, float localX, float localY) {
- this.setPosition(e.getX() - this.getWidth()/2, e.getY() - this.getHeight()/2);
- return true;
- }
- };
- //scene.attachChild(background);
- scene.attachChild(face);
- scene.registerTouchArea(face);*/
- scene.setTouchAreaBindingEnabled(true);
- return scene;
- }
- @Override
- public void onLoadComplete() {
- }
- // ===========================================================
- // Methods
- // ===========================================================
- private ColorBackground getBackgroundColor(int r, int g, int b) {
- return new ColorBackground(1.0f/r, 1.0f/g, 1.0f/b);
- }
- //private void createScene()
- private void loadNewTexture(Scene scene, String texturePath, int width, int height, int x, int y) {
- Texture texture = new Texture(width, height, TextureOptions.BILINEAR_PREMULTIPLYALPHA);
- TextureRegion textureReg = TextureRegionFactory.createFromAsset(texture, this, texturePath, 0, 0);
- this.mEngine.getTextureManager().loadTexture(texture);
- scene.attachChild(new Sprite(x, y, textureReg));
- }
- // ===========================================================
- // Inner and Anonymous Classes
- // ===========================================================
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement