Example #1
0
 @Override
 public void onResumeGame() {
   super.onResumeGame();
   mMainScene.registerEntityModifier(
       new ScaleAtModifier(0.5f, 0.0f, 1.0f, CAMERA_WIDTH / 2, CAMERA_HEIGHT / 2));
   mOptionsMenuScene.registerEntityModifier(
       new ScaleAtModifier(0.5f, 0.0f, 1.0f, CAMERA_WIDTH / 2, CAMERA_HEIGHT / 2));
 }
  @Override
  public void onDestroy() {
    if (null != clientProxy) {
      clientProxy.disconnect();
    }

    if (null != serverProxy) {
      serverProxy.disconnect();
    }

    super.onDestroy();
  }
  @Override
  public void loadResources(BaseGameActivity context) {
    this.isLoaded = true;
    mScene.setTouchAreaBindingEnabled(true);

    // background
    SceneManager.bg_bitmapTextureAtlas.clearTextureAtlasSources();
    SceneManager.bg_textureRegion =
        BitmapTextureAtlasTextureRegionFactory.createFromAsset(
            SceneManager.bg_bitmapTextureAtlas,
            context,
            "gfx/game script/level selector/MenuChoice_background.png",
            0,
            0);
    SceneManager.loadTexture(SceneManager.bg_bitmapTextureAtlas);

    SceneManager.bg_sprite = new Sprite(0, 0, SceneManager.bg_textureRegion);
    mScene.setBackground(new SpriteBackground(SceneManager.bg_sprite));

    // menu
    this.SheetMenuBitmapTextureAtlas = new BitmapTextureAtlas(256, 128, TextureOptions.DEFAULT);
    this.Level_1_TextureRegion =
        BitmapTextureAtlasTextureRegionFactory.createFromAsset(
            this.SheetMenuBitmapTextureAtlas,
            context,
            "gfx/game script/level selector/Level_1.png",
            0,
            0);
    this.Level_2_TextureRegion =
        BitmapTextureAtlasTextureRegionFactory.createFromAsset(
            this.SheetMenuBitmapTextureAtlas,
            context,
            "gfx/game script/level selector/Level_2.png",
            0,
            40);

    SceneManager.loadTexture(this.SheetMenuBitmapTextureAtlas);

    Level_1 =
        new Sprite(
            context.getEngine().getCamera().getWidth() / 2 - Level_1_TextureRegion.getWidth() / 2,
            100,
            this.Level_1_TextureRegion) {

          // chuyen sang chon level
          @Override
          public boolean onAreaTouched(
              final TouchEvent pSceneTouchEvent,
              final float pTouchAreaLocalX,
              final float pTouchAreaLocalY) {
            if (pSceneTouchEvent.getAction() == TouchEvent.ACTION_DOWN) {
              SceneManager.Menu_id = SceneManager.GAME_PLAY;
              LevelManager.Level = LevelManager.LEVEL_1_CLASS;
              SceneManager.load();
              SceneManager.setScene(SceneManager.run());
            }
            return true;
          }
        };

    Level_2 =
        new Sprite(
            context.getEngine().getCamera().getWidth() / 2 - Level_1_TextureRegion.getWidth() / 2,
            200,
            this.Level_2_TextureRegion) {

          // Thoat khoi game
          @Override
          public boolean onAreaTouched(
              final TouchEvent pSceneTouchEvent,
              final float pTouchAreaLocalX,
              final float pTouchAreaLocalY) {
            if (pSceneTouchEvent.getAction() == TouchEvent.ACTION_DOWN) {
              SceneManager.Menu_id = SceneManager.GAME_PLAY;
              LevelManager.Level = LevelManager.LEVEL_2_MARKET;
              SceneManager.load();
              SceneManager.setScene(SceneManager.run());
            }
            return true;
          }
        };
    mScene.attachChild(Level_1);
    mScene.attachChild(Level_2);

    mScene.registerTouchArea(Level_1);
    mScene.registerTouchArea(Level_2);
  }
 /** Called when the activity is first created. */
 @Override
 public void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   // setContentView(R.layout.main);
 }