Package com.mygdx.game.Entitys
Class Obstacle
- java.lang.Object
-
- com.mygdx.game.Entitys.Entity
-
- com.mygdx.game.Entitys.Obstacle
-
- All Implemented Interfaces:
CollisionCallBack
- Direct Known Subclasses:
Weather
public class Obstacle extends Entity implements CollisionCallBack
// Added for Assessment 2 Requirements // A class for obstacles in the game world, both trigger or contact.
-
-
Constructor Summary
Constructors Constructor Description Obstacle(java.lang.String texName, boolean trigger, float damage)
Generate an obstacle which only triggers a hit on initial collision and does not break.Obstacle(java.lang.String texName, boolean trigger, float damage, float hitRate, int hitLimit)
Generate an obstacle.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
BeginContact(CollisionInfo info)
Takes the collision info and verifies the results of the collisionvoid
EndContact(CollisionInfo info)
Sets the obstacle's status as not collidingvoid
EnterTrigger(CollisionInfo info)
Takes the collision info and verifies the results of the collisionvoid
ExitTrigger(CollisionInfo info)
Sets the obstacle's status as not collidingvoid
kill()
Sets the obstacle to be removed on next updatevoid
update()
Runs once per frame-
Methods inherited from class com.mygdx.game.Entitys.Entity
addComponent, addComponents, cleanUp, dispose, getComponent, getComponent, getName, raiseEvents, setName
-
-
-
-
Constructor Detail
-
Obstacle
public Obstacle(java.lang.String texName, boolean trigger, float damage)
Generate an obstacle which only triggers a hit on initial collision and does not break.- Parameters:
texName
- The texture to show for the obstacle.trigger
- True if the obstacle is trigger, otherwise is contact.damage
- The damage that the obstacle does per 'hit'
-
Obstacle
public Obstacle(java.lang.String texName, boolean trigger, float damage, float hitRate, int hitLimit)
Generate an obstacle.- Parameters:
texName
- The texture to show for the obstacle.trigger
- True if the obstacle is trigger, otherwise is contact.damage
- The damage that the obstacle does per 'hit'hitRate
- The rate at which 'hits' occur while collidinghitLimit
- The number of 'hits' required to break the obstacle
-
-
Method Detail
-
kill
public void kill()
Sets the obstacle to be removed on next update
-
BeginContact
public void BeginContact(CollisionInfo info)
Takes the collision info and verifies the results of the collision- Specified by:
BeginContact
in interfaceCollisionCallBack
- Parameters:
info
- the info linked to the collision
-
EndContact
public void EndContact(CollisionInfo info)
Sets the obstacle's status as not colliding- Specified by:
EndContact
in interfaceCollisionCallBack
-
EnterTrigger
public void EnterTrigger(CollisionInfo info)
Takes the collision info and verifies the results of the collision- Specified by:
EnterTrigger
in interfaceCollisionCallBack
- Parameters:
info
- the info linked to the collision
-
ExitTrigger
public void ExitTrigger(CollisionInfo info)
Sets the obstacle's status as not colliding- Specified by:
ExitTrigger
in interfaceCollisionCallBack
-
-