Projectiles is a arrayList of Projectile.
There are a couple subClasses of Projectile like Laser.
Here im trying to pass a Projectile into another function.
void checkProjectiles() {
for (int index=0; index<Projectiles.size (); index++) {
if (sq(Projectiles.get(index).xPos - posX) + sq(Projectiles.get(index).yPos - posY) < sq(size)) { //if within the a circle radius of size from centre of roid
Projectile checkProjectile = Projectiles.get(index);
collision(checkProjectile);
}
}
}
My problem is that when passing an instance of Laser into this function, instead of going to collision(Laser laser) it goes to collision(Projectile projectile) instead.
How do I get the object to pass as an instance of its specific subClass?