Hi ! I need some help for getting coordonate X and Y from an element of a list made by getObjectsInRange()
My actor here (Flamme) , needs to have the X and Y from another actor (Bateau) to move towards this actor and destroy it, but I can't find the right code to have this coordinates. Could you help me ?
Here is my code :
An error come after the cible.getX() : cannot find symbol- method getX()
I understood that it's because cible is just an element of the list and doesn't have coordinates but I don't know how to get them.
(P.S : I'm swiss and speak french so sorry for my english )
import greenfoot.*; /** * Projectile infligeant des dégats aux ennemis. * * @author - * @version 1.0.0 */ public class Flamme extends Dragon { /** * Le projectile se dirige vers sa cible. */ public void act() { move(5); } private void cible() { java.util.List lescibles = getObjectsInRange(250, Bateau.class); Object cible = lescibles.get(0); turnTowards(cible.getX(), cible.getY()); } }