Genuts API

com.genuts.gameui
Interface CollisionManager

All Known Implementing Classes:
LCDCollisionManager, SpriteCollisionManager

public interface CollisionManager

Defines an interface for classes that know how to check collision between sprites.

A collision manager can manage only one playfield.

See Also:
PlayField

Method Summary
 void addSprite(Sprite sprite)
          Adds a sprite in the check list of this collision manager.
 void checkAllCollisions()
          Checks collisions of sprites with all other sprites in the playfield, and with the edges of the playfield.
 void checkCollision(Sprite sprite)
          Checks collision of the given sprite with all other sprites in the playfield, and with the edges of the playfield.
 void drawDebug(java.awt.Graphics g)
          Draws debug informations for this collision manager.
 PlayField getPlayfield()
          Returns the playfield associated with this collision manager.
 void invalidateSprite(Sprite sprite)
          Performs actions when a sprite is invalidate.
 void playfieldSizeChanged()
          Informs that the size of the playfield has changed.
 boolean preCheckCollision(Sprite sprite)
          Checks pre-collision of the given sprite with all other sprites in this playfield, and with the edges of this playfield.
 void removeSprite(Sprite sprite)
          Removes a sprite from the check list of this collision manager.
 void reset()
          Resets cache datas for this CollisionManager.
 void setPlayfield(PlayField playfield)
          Sets the playfield associated with this collision manager.
 void validateSprite(Sprite sprite)
          Performs actions when a sprite is validate.
 

Method Detail

getPlayfield

public PlayField getPlayfield()
Returns the playfield associated with this collision manager.

Returns:
The playfield associated with this collision manager.

setPlayfield

public void setPlayfield(PlayField playfield)
Sets the playfield associated with this collision manager.

Parameters:
playfield - The playfield associated with this collision manager.

playfieldSizeChanged

public void playfieldSizeChanged()
Informs that the size of the playfield has changed.


reset

public void reset()
Resets cache datas for this CollisionManager.


preCheckCollision

public boolean preCheckCollision(Sprite sprite)
Checks pre-collision of the given sprite with all other sprites in this playfield, and with the edges of this playfield.

If one or more pre-collisions are detected, firePreCollisionEvent(Sprite, Sprite) is called.

Parameters:
sprite - Sprite to check
Returns:
true to confirm the state of the sprite, false otherwise.
See Also:
checkCollision(Sprite), PlayField.firePreCollisionEvent(Sprite, Sprite)

checkCollision

public void checkCollision(Sprite sprite)
Checks collision of the given sprite with all other sprites in the playfield, and with the edges of the playfield. If one or more collisions are detected, fireCollisionEvent(Sprite, Sprite) is called.

Parameters:
sprite - Sprite to check
See Also:
PlayField.fireCollisionEvent(Sprite, Sprite)

checkAllCollisions

public void checkAllCollisions()
Checks collisions of sprites with all other sprites in the playfield, and with the edges of the playfield. If one or more collisions are detected, fireCollisionEvent(Sprite, Sprite) is called.

See Also:
PlayField.fireCollisionEvent(Sprite, Sprite)

addSprite

public void addSprite(Sprite sprite)
Adds a sprite in the check list of this collision manager.

Generally, this is called by the playfield when a new sprite is added.

Parameters:
sprite - Sprite to add

removeSprite

public void removeSprite(Sprite sprite)
Removes a sprite from the check list of this collision manager.

Generally, this is called by the playfield when a sprite is removed.

Parameters:
sprite - Sprite to remove

invalidateSprite

public void invalidateSprite(Sprite sprite)
Performs actions when a sprite is invalidate.

Generally, this is called by a sprite when Sprite.invalidate() is called.

Parameters:
sprite - Sprite to invalidate.
See Also:
Sprite.invalidate()

validateSprite

public void validateSprite(Sprite sprite)
Performs actions when a sprite is validate.

Generally, this is called by a sprite when Sprite.validate() is called.

Parameters:
sprite - Sprite to validate.
See Also:
Sprite.validate()

drawDebug

public void drawDebug(java.awt.Graphics g)
Draws debug informations for this collision manager.

Parameters:
g - The graphics context to use for painting.

Genuts API

Genuts API