Back to project page myGame.
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.
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(); } } }