|
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
com.golden.gamedev.object.collision.BasicCollisionGroup
com.golden.gamedev.object.collision.CollisionGroup
com.golden.gamedev.object.collision.PreciseCollisionGroup
com.golden.gamedev.object.collision.AdvanceCollisionGroup
public abstract class AdvanceCollisionGroup
Accurates collision check that able to check collision between one sprite with many sprites (one to many collision check).
This collision check is the most advance among all other collision check, it checking is the collision really occured or not.
For example:
A sprite is checked its collision with three other sprites,
if the checking only based on the sprite position, the sprite is collided
with the three other sprites. But if the sprite is collided with the first
sprite and stop, the sprite actually only collide with the first,
because the second and the third is right behind the first sprite.
This collision group is suitable for collision that using physics heavily, like in platformer game, where a sprite could collide with many blocks at one time.
Field Summary |
---|
Fields inherited from class com.golden.gamedev.object.collision.CollisionGroup |
---|
BOTTOM_TOP_COLLISION, collisionSide, collisionX1, collisionX2, collisionY1, collisionY2, LEFT_RIGHT_COLLISION, RIGHT_LEFT_COLLISION, sprite1, sprite2, TOP_BOTTOM_COLLISION |
Fields inherited from class com.golden.gamedev.object.collision.BasicCollisionGroup |
---|
pixelPerfectCollision, rect1, rect2 |
Constructor Summary | |
---|---|
AdvanceCollisionGroup()
Constructs new AdvanceCollisionGroup . |
Method Summary | |
---|---|
void |
checkCollision()
Checks for collision between all members in group 1 againts all members in group 2. |
int |
compare(Object o1,
Object o2)
Sorts two sprites ( o1 and o2 ) that collided
with the object sprite to determine
which one should be checked first. |
protected Sprite |
getSourceSprite()
Returns the source sprite to be checked at the moment. |
Map |
getStorage()
Returns collided sprites storage. |
protected boolean |
sort(Sprite source)
Determines all sprites that collided with Sprite source
should be sorted or not before checking the actual collision. |
Methods inherited from class com.golden.gamedev.object.collision.PreciseCollisionGroup |
---|
isCollide |
Methods inherited from class com.golden.gamedev.object.collision.CollisionGroup |
---|
getCollisionSide, getSprite1, getSprite2, printCollisionSide, revertPosition1, revertPosition2 |
Methods inherited from class com.golden.gamedev.object.collision.BasicCollisionGroup |
---|
collided, getCollisionShape1, getCollisionShape2 |
Methods inherited from class com.golden.gamedev.object.CollisionManager |
---|
getGroup1, getGroup2, getIntersectionRect, isActive, isPixelCollide, setActive, setCollisionGroup |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface java.util.Comparator |
---|
equals |
Constructor Detail |
---|
public AdvanceCollisionGroup()
AdvanceCollisionGroup
.
Method Detail |
---|
public void checkCollision()
CollisionManager
checkCollision
in class BasicCollisionGroup
protected boolean sort(Sprite source)
source
should be sorted or not before checking the actual collision. By default this method return true in order to sort the collided sprites.
compare(Object, Object)
public int compare(Object o1, Object o2)
o1
and o2
) that collided
with the object sprite to determine
which one should be checked first. By default when the object sprite is falling (vertical speed >= 0), all collided sprites are sorted by greater y at bottom, otherwise it sort by greater y at top.
compare
in interface Comparator
protected Sprite getSourceSprite()
Source sprite is the sprite from group 1 that will be checked its actual collision with sprite from group 2.
public Map getStorage()
Mapping a sprite with its collided sprites.
|
GTGE API | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |