Class ProjectileAttackComponent


public class ProjectileAttackComponent extends TouchAttackComponent
A component that allows an entity to attack other entities upon collision, dealing damage and applying knockback.

This component should be added to a projectile entity. It requires the entity to have a CombatStatsComponent to define its damage capabilities and a HitboxComponent to detect collisions. When a collision is detected with an entity on the specified target layer, this component will deal damage to the target if it has a CombatStatsComponent. The projectile is then disposed of after the collision.

  • Constructor Details

    • ProjectileAttackComponent

      public ProjectileAttackComponent(short targetLayer, int damage, Entity target)
      Constructs a ProjectileAttackComponent for handling attacks on entities upon collision. The component is configured to target entities in a specific physics layer.
      Parameters:
      targetLayer - The physics layer of the target entities' collider.
      damage - the amount of damage this projectile does
  • Method Details

    • onCollisionStart

      protected void onCollisionStart(com.badlogic.gdx.physics.box2d.Fixture me, com.badlogic.gdx.physics.box2d.Fixture other)
      Overrides:
      onCollisionStart in class TouchAttackComponent