com.golden.gamedev.genre.platform
Class PlatformCollision
java.lang.Object
|
+--com.golden.gamedev.object.CollisionGroupStandard
|
+--com.golden.gamedev.object.CollisionGroup
|
+--com.golden.gamedev.object.CollisionGroupPrecise
|
+--com.golden.gamedev.genre.platform.PlatformCollision
- All Implemented Interfaces:
- CollisionGroupManager, Comparator
- public abstract class PlatformCollision
- extends CollisionGroupPrecise
- implements Comparator
CollisionGroup that used very accurate collision calculation event.
In platform game, there are many blocks to hold,
and collision with that blocks must be very accurate
to determine the sprite movement. Collision in platform game is not like
other type of game (destroy the collided sprite, bounce, etc),
but physics is heavily used in here.
Because of there are many blocks, sometimes could be happen,
that a sprite collided with many blocks (three to six at a time).
If using standard collision group, all the collision events is directly send
to the listener, there's no check is the collision really occured or not.
Therefore this class is specially designed for sprite that collision with
many other sprites. The collision events is not directly send
to the listener. All collision events is collected and then calculated
accurately before send to the listener.
Fields inherited from class com.golden.gamedev.object.CollisionGroup |
BOTTOM_TOP_COLLISION, collisionSide, collisionX1, collisionX2, collisionY1, collisionY2, LEFT_RIGHT_COLLISION, RIGHT_LEFT_COLLISION, sprite1, sprite2, TOP_BOTTOM_COLLISION |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
ASCENDING_Y
public static final int ASCENDING_Y
- See Also:
- Constant Field Values
DESCENDING_Y
public static final int DESCENDING_Y
- See Also:
- Constant Field Values
PlatformCollision
public PlatformCollision(SpriteGroup group1,
SpriteGroup group2)
PlatformCollision
public PlatformCollision()
sort
protected boolean sort(Sprite source)
- Determines all sprites that collide with Sprite
source
should be sorted or not before checking is the collision really occured.
Commonly when Sprite source
is falling
(vertical speed >= 0),
all collided sprites is sorted ascending
(greater y at bottom), otherwise it sort
descending (greater y at top).
- Returns:
- true, sprites will be sorted before checking the actual collision
checkCollision
public void checkCollision()
- Specified by:
checkCollision
in interface CollisionGroupManager
- Overrides:
checkCollision
in class CollisionGroupStandard
interestCollide
public boolean interestCollide(Sprite s1,
Sprite s2)
collided2
public abstract void collided2(Sprite sprite1,
Sprite sprite2)
collided
public final void collided(Sprite sprite1,
Sprite sprite2)
- Collects all collided sprites event into
HashMap collection.
- Specified by:
collided
in class CollisionGroupStandard
compare
public int compare(Object o1,
Object o2)
- Specified by:
compare
in interface Comparator
getStorage
public HashMap getStorage()