GTGE API

com.golden.gamedev.object.collision
Class CollisionBounds

java.lang.Object
  extended by com.golden.gamedev.object.CollisionManager
      extended by com.golden.gamedev.object.collision.CollisionBounds

public abstract class CollisionBounds
extends CollisionManager

Checks collision for specified boundary.


Field Summary
static int BOTTOM_COLLISION
          Indicates the sprite is collided at its bottom.
static int LEFT_COLLISION
          Indicates the sprite is collided at its left.
protected  CollisionRect rect1
          Default sprite bounding box used in getCollisionShape1(Sprite).
static int RIGHT_COLLISION
          Indicates the sprite is collided at its right.
static int TOP_COLLISION
          Indicates the sprite is collided at its top.
 
Constructor Summary
CollisionBounds(Background backgr)
          Creates new CollisionBounds with specified background as the boundary.
CollisionBounds(int x, int y, int width, int height)
          Creates new CollisionBounds with specified boundary.
 
Method Summary
 void checkCollision()
          Checks for collision between all members in group 1 againts all members in group 2.
abstract  void collided(Sprite sprite)
          Sprite sprite hit collision boundary, perform collided implementation.
 Rectangle getBoundary()
          Returns the boundary of the sprites.
 CollisionShape getCollisionShape1(Sprite s1)
          Sets specified Sprite collision rectangle (sprite bounding box) into rect.
 boolean isCollisionSide(int side)
          Returns true, the sprite is collide at it side side.
 void revertPosition1()
          Reverts the sprite position before the collision occured.
 void setBoundary(int x, int y, int width, int height)
          Sets the collision boundary, the sprite is bounded to this boundary.
 void setCollisionGroup(SpriteGroup group1, SpriteGroup group2)
          Associates specified sprite groups to this manager.
 
Methods inherited from class com.golden.gamedev.object.CollisionManager
getGroup1, getGroup2, getIntersectionRect, isActive, isPixelCollide, setActive
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LEFT_COLLISION

public static final int LEFT_COLLISION
Indicates the sprite is collided at its left.

See Also:
Constant Field Values

RIGHT_COLLISION

public static final int RIGHT_COLLISION
Indicates the sprite is collided at its right.

See Also:
Constant Field Values

TOP_COLLISION

public static final int TOP_COLLISION
Indicates the sprite is collided at its top.

See Also:
Constant Field Values

BOTTOM_COLLISION

public static final int BOTTOM_COLLISION
Indicates the sprite is collided at its bottom.

See Also:
Constant Field Values

rect1

protected final CollisionRect rect1
Default sprite bounding box used in getCollisionShape1(Sprite).

Constructor Detail

CollisionBounds

public CollisionBounds(int x,
                       int y,
                       int width,
                       int height)
Creates new CollisionBounds with specified boundary.


CollisionBounds

public CollisionBounds(Background backgr)
Creates new CollisionBounds with specified background as the boundary.

Method Detail

setCollisionGroup

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

Overrides:
setCollisionGroup in class CollisionManager
See Also:
CollisionManager.checkCollision()

checkCollision

public void checkCollision()
Description copied from class: CollisionManager
Checks for collision between all members in group 1 againts all members in group 2.

Specified by:
checkCollision in class CollisionManager

revertPosition1

public void revertPosition1()
Reverts the sprite position before the collision occured.


getCollisionShape1

public CollisionShape getCollisionShape1(Sprite s1)
Sets specified Sprite collision rectangle (sprite bounding box) into rect.

In this implementation, the sprite bounding box is as large as Sprite dimension :

     public boolean getCollisionRect1(Sprite s1, CollisionRect rect) {
         rect.setBounds(s1.getX(), s1.getY(),
                        s1.getWidth(), s1.getHeight());
         return rect;
     }
 

Returns:
false, to skip collision check.
See Also:
CollisionRect.intersects(CollisionShape)

isCollisionSide

public boolean isCollisionSide(int side)
Returns true, the sprite is collide at it side side.


setBoundary

public void setBoundary(int x,
                        int y,
                        int width,
                        int height)
Sets the collision boundary, the sprite is bounded to this boundary.


getBoundary

public Rectangle getBoundary()
Returns the boundary of the sprites.


collided

public abstract void collided(Sprite sprite)
Sprite sprite hit collision boundary, perform collided implementation.


GTGE API

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