Android Open Source - androidtbsgame Game Scene






From Project

Back to project page androidtbsgame.

License

The source code is released under:

MIT License

If you think the Android project androidtbsgame listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package de.mmssb.androidtbsgame.andengine.scenes;
/* w  ww . j  a v  a2 s . c  o  m*/
import java.util.ArrayList;
import java.util.List;

import org.andengine.entity.scene.IOnSceneTouchListener;
import org.andengine.entity.scene.Scene;
import org.andengine.input.touch.TouchEvent;
import org.andengine.util.color.Color;

import de.mmssb.androidtbsgame.andengine.Model;
import de.mmssb.androidtbsgame.andengine.entities.board.Board;
import de.mmssb.androidtbsgame.andengine.entities.board.Mark;

/**
 * @author Manu
 * 
 */
public class GameScene extends ModelScene implements IOnSceneTouchListener {
  private Board board;

  /**
   * Creates an instance of {@link GameScene}
   * 
   * @param model
   *            {@link Model} reference
   */
  public GameScene(Model model) {
    super(model);
  }

  /*
   * (non-Javadoc)
   * 
   * @see de.mmssb.aweproject.scenes.ModelScene#initialize()
   */
  @Override
  public void initialize() {
    setOnSceneTouchListener(this);
  }

  private Mark testMark;

  /*
   * XXX TEST
   * 
   * (non-Javadoc)
   * 
   * @see
   * org.andengine.entity.scene.IOnSceneTouchListener#onSceneTouchEvent(org
   * .andengine.entity.scene.Scene, org.andengine.input.touch.TouchEvent)
   */
  @Override
  public boolean onSceneTouchEvent(final Scene pScene,
      final TouchEvent pTouchEvent) {
    if (pTouchEvent.isActionUp()) {
      if (testMark != null) {
        testMark.detachSelf();
        testMark = null;
      }
    } else if (pTouchEvent.isActionDown()) {
      getModel().handleGameSceneSwipe(pTouchEvent.getX(),
          pTouchEvent.getY());
      int[] columnAndRow = board.getClickedColumnAndRow(
          pTouchEvent.getX(), pTouchEvent.getY());
      List<int[]> list = new ArrayList<int[]>();
      list.add(new int[] { columnAndRow[0], columnAndRow[1] });
      list.add(new int[] { columnAndRow[0] - 1, columnAndRow[1] });
      list.add(new int[] { columnAndRow[0] + 1, columnAndRow[1] });
      list.add(new int[] { columnAndRow[0], columnAndRow[1] - 1 });
      list.add(new int[] { columnAndRow[0] - 1, columnAndRow[1] - 1 });
      list.add(new int[] { columnAndRow[0] + 1, columnAndRow[1] - 1 });
      list.add(new int[] { columnAndRow[0], columnAndRow[1] + 1 });
      list.add(new int[] { columnAndRow[0] - 1, columnAndRow[1] + 1 });
      list.add(new int[] { columnAndRow[0] + 1, columnAndRow[1] + 1 });
      testMark = new Mark(getModel(), board, list, Color.RED, 0.6f,
          0.25f, 0.5f);
      board.attachChild(testMark);
    }
    return true;
  }

  public void setBoard(Board board) {
    if (board != null) {
      board.detachSelf();
    }
    this.board = board;
    attachChild(board);
  }

  public Board getBoard() {
    return board;
  }
}




Java Source Code List

de.mmssb.androidtbsgame.andengine.BoardMap.java
de.mmssb.androidtbsgame.andengine.GameControl.java
de.mmssb.androidtbsgame.andengine.MainActivity.java
de.mmssb.androidtbsgame.andengine.Model.java
de.mmssb.androidtbsgame.andengine.entities.board.Board.java
de.mmssb.androidtbsgame.andengine.entities.board.Cell.java
de.mmssb.androidtbsgame.andengine.entities.board.Mark.java
de.mmssb.androidtbsgame.andengine.hud.ImageButtonSprite.java
de.mmssb.androidtbsgame.andengine.hud.ModelHUD.java
de.mmssb.androidtbsgame.andengine.managers.CellControl.java
de.mmssb.androidtbsgame.andengine.managers.Manager.java
de.mmssb.androidtbsgame.andengine.managers.ResourceManager.java
de.mmssb.androidtbsgame.andengine.managers.SceneManager.java
de.mmssb.androidtbsgame.andengine.managers.SharedPreferencesManager.java
de.mmssb.androidtbsgame.andengine.scenes.GameScene.java
de.mmssb.androidtbsgame.andengine.scenes.ModelScene.java
de.mmssb.androidtbsgame.andengine.units.AnimationProperties.java