Android Open Source - myGame Collision Manager






From Project

Back to project page myGame.

License

The source code is released under:

MIT License

If you think the Android project myGame 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 com.mygdx.mygame;
/* ww w  .j  a  v a  2  s. c o m*/
import com.badlogic.gdx.graphics.g2d.Sprite;

public class CollisionManager {

  private AnimatedSprite spaceshipAnimated;
  private Enemy enemy;
  private ShotManager shotManager;

  public CollisionManager(AnimatedSprite spaceshipAnimated, Enemy enemy,
      ShotManager shotManager) {
        this.spaceshipAnimated = spaceshipAnimated;
        this.enemy = enemy;
        this.shotManager = shotManager;
  }

  public  void handleCollisions() {
    handleEnemyShot();
    handlePlayerShot();
    
  }

  private void handlePlayerShot() {
    if(shotManager.enemyShotTouches(spaceshipAnimated.getBoundingBox()))
    {
      spaceshipAnimated.setDead(true);
    }
    
  }

  private  void handleEnemyShot() {
    if(shotManager.playerShotTouches(enemy.GetBoundingBox()))
    {
      enemy.hit();
    }
    
  }

}




Java Source Code List

com.mygdx.mygame.AnimatedSprite.java
com.mygdx.mygame.CollisionManager.java
com.mygdx.mygame.Enemy.java
com.mygdx.mygame.MyGdxGame.java
com.mygdx.mygame.ShotManager.java
com.mygdx.mygame.android.AndroidLauncher.java
com.mygdx.mygame.desktop.DesktopLauncher.java