GTGE API

com.golden.gamedev.object
Class CollisionManager

java.lang.Object
  extended by com.golden.gamedev.object.CollisionManager
Direct Known Subclasses:
BasicCollisionGroup, CollisionBounds

public abstract class CollisionManager
extends Object

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.

See Also:
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

CollisionManager

public CollisionManager()
Creates new CollisionManager.

Method Detail

setCollisionGroup

public void setCollisionGroup(SpriteGroup group1,
                              SpriteGroup group2)
Associates specified sprite groups to this manager. The groups will be checked its collision one against another.

See Also:
checkCollision()

getGroup1

public SpriteGroup getGroup1()
Returns the first group associated with this collision manager.


getGroup2

public SpriteGroup getGroup2()
Returns the second group associated with this collision manager.


checkCollision

public abstract void checkCollision()
Checks for collision between all members in group 1 againts all members in group 2.


isActive

public boolean isActive()
Returns true, if this collision manager is active. Inactive collision manager won't perform any collision check.

See Also:
setActive(boolean)

setActive

public void setActive(boolean b)
Sets the active state of this collision manager. Inactive collision manager won't perform any collision check.

See Also:
isActive()

isPixelCollide

public 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.


getIntersectionRect

public 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.


GTGE API

Copyright © 2003-2005 Golden T Studios. All rights reserved. Use is subject to license terms.
GoldenStudios.or.id