Attacking Class
A component class responsible for attacking.
Constructor
Attacking
-
attack
-
rightAttackPointX
-
rightAttackPointY
-
rightAttackDirectionX
-
rightAttackDirectionY
-
attackCooldown
-
foeCollideWith
Parameters:
-
attack
MeleeAttack | RangedAttackAn object describing the type of attack the entity will perform.
-
rightAttackPointX
NumberThe x component of the attack point. The attack point is a position relative to the entity's position from which an attack will be performed. For melee attacks, it's the center point for the scan shape, for ranged attacks it's the point from which projectiles will be fired. This point is for when an entity attacks while facing to the right, the left variant is calculated automatically.
-
rightAttackPointY
NumberThe y component of the attack point. The attack point is a position relative to the entity's position from which an attack will be performed. For melee attacks, it's the center point for the scan shape, for ranged attacks it's the point from which projectiles will be fired. This point is for when an entity attacks while facing to the right, the left variant is calculated automatically.
-
rightAttackDirectionX
NumberThe x component of the direction vector. The vector should be pointing in the attack direction when an entity is facing to the right, the left variant is calculated automatically. This vector needs to be normalized. A direction is only required if the attack type is ranged.
-
rightAttackDirectionY
NumberThe y component of the direction vector. The vector should be pointing in the attack direction when an entity is facing to the right, the left variant is calculated automatically. This vector needs to be normalized. A direction is only required if the attack type is ranged.
-
attackCooldown
NumberAttack cooldown needs to be in seconds.
-
foeCollideWith
NumberA bit mask used when querying the physics engine for enemy entities.
Item Index
Methods
canAttack
()
Boolean
Check whether the entity is ready to attack.
Returns:
getAttackCooldown
()
Number
Returns the attack cooldown.
Returns:
getAttackCooldownRemaining
()
Number
Returns the remaining attack cooldown.
Returns:
getFoeCollideWith
()
Number
Returns:
getRightAttackDirection
-
vector
Parameters:
-
vector
Vector2DVector to which the attack direction will be copied.
getRightAttackPoint
-
vector
Parameters:
-
vector
Vector2DVector to which the attack point will be copied.
setFoeCollideWith
-
foeCollideWith
Parameters:
-
foeCollideWith
NumberA bit mask used when querying the physics engine for enemy entities.
setRightAttackDirection
-
x
-
y
Parameters:
-
x
NumberThe x component of the direction vector. The vector should be pointing in the attack direction when an entity is facing to the right, the left variant is calculated automatically. This vector needs to be normalized. A direction is only required if the attack type is ranged.
-
y
NumberThe y component of the direction vector. The vector should be pointing in the attack direction when an entity is facing to the right, the left variant is calculated automatically. This vector needs to be normalized. A direction is only required if the attack type is ranged.
setRightAttackPoint
-
x
-
y
Parameters:
-
x
NumberThe x component of the attack point. The attack point is a position relative to the entity's position from which an attack will be performed. For melee attacks, it's the center point for the scan shape, for ranged attacks it's the point from which projectiles will be fired. This point is for when an entity attacks while facing to the right, the left variant is calculated automatically.
-
y
NumberThe y component of the attack point. The attack point is a position relative to the entity's position from which an attack will be performed. For melee attacks, it's the center point for the scan shape, for ranged attacks it's the point from which projectiles will be fired. This point is for when an entity attacks while facing to the right, the left variant is calculated automatically.