Back to project page Castle-Invaders.
The source code is released under:
GNU General Public License
If you think the Android project Castle-Invaders 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.noobygames.castleinvaders; /*ww w.j a v a 2s . c o m*/ import com.badlogic.gdx.math.Rectangle; import com.badlogic.gdx.math.Vector2; public class GameObject { public final Vector2 position; public final Rectangle bounds; public GameObject(float x, float y, float width, float height) { this.position = new Vector2(x, y); this.bounds = new Rectangle(x - width / 2, y - height / 2, width, height); } public GameObject(Rectangle bounds){ this.bounds = bounds; this.position = new Vector2(bounds.getX(), bounds.getY()); } public void resetBoundsWithPosition() { this.bounds.x = this.position.x - this.bounds.width / 2; this.bounds.y = this.position.y - this.bounds.height / 2; } }