|
GTGE API | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.golden.gamedev.object.CollisionManager
public abstract class CollisionManager
CollisionManager
class is the base collision check abstract
class that check collision between two SpriteGroups
.
The collision check is the subclass responsibility.
In Golden T Game Engine (GTGE) Frame Work, sprites are grouped into
SpriteGroup
and collision is checked between two sprite groups.
This technique reduces code programming, increases readability,
simplify collision event, and improves collision check.
CollisionManager
is added into PlayField
using
PlayField.addCollisionGroup(SpriteGroup, SpriteGroup, CollisionManager)
,
and then the PlayField
manage the collision check everytime the
PlayField is updated.
PlayField.addCollisionGroup(SpriteGroup, SpriteGroup, CollisionManager)
Constructor Summary | |
---|---|
CollisionManager()
Creates new CollisionManager . |
Method Summary | |
---|---|
abstract void |
checkCollision()
Checks for collision between all members in group 1 againts all members in group 2. |
SpriteGroup |
getGroup1()
Returns the first group associated with this collision manager. |
SpriteGroup |
getGroup2()
Returns the second group associated with this collision manager. |
static CollisionRect |
getIntersectionRect(double x1,
double y1,
int width1,
int height1,
double x2,
double y2,
int width2,
int height2)
Returns the intersection rect of two rectangle. |
boolean |
isActive()
Returns true, if this collision manager is active. |
static boolean |
isPixelCollide(double x1,
double y1,
BufferedImage image1,
double x2,
double y2,
BufferedImage image2)
Returns true whether image1 at x1 , y1
collided with image2 at x2 , y2 . |
void |
setActive(boolean b)
Sets the active state of this collision manager. |
void |
setCollisionGroup(SpriteGroup group1,
SpriteGroup group2)
Associates specified sprite groups to this manager. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public CollisionManager()
CollisionManager
.
Method Detail |
---|
public void setCollisionGroup(SpriteGroup group1, SpriteGroup group2)
checkCollision()
public SpriteGroup getGroup1()
public SpriteGroup getGroup2()
public abstract void checkCollision()
public boolean isActive()
setActive(boolean)
public void setActive(boolean b)
isActive()
public static boolean isPixelCollide(double x1, double y1, BufferedImage image1, double x2, double y2, BufferedImage image2)
image1
at x1
, y1
collided with image2
at x2
, y2
.
public static CollisionRect getIntersectionRect(double x1, double y1, int width1, int height1, double x2, double y2, int width2, int height2)
|
GTGE API | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |