public void move()
{
//if (this.getWorld().getObjects(Marker.class).isEmpty())
Dog bill = getOneIntersectingObject(Dog.class);
Marker bone = getOneIntersectingObject(Dog.class);
if (bone == null);
{
Marker bone= new Marker();
getWorld().addObject(marker.getX(), marker.getY());
}
super.move(1);
}
I'm trying to reference the location of my current actor subclass (dog) in order to place a marker(bone) of another subclass at the coordinates it is located at.
You can retrieve the coordinates of the actor by calling
getX()andgetY(), as you do it for other actors.If you like to call methods for the "current" actor, you might like to use
this, in examplethis.getX(). But it is only necessary, if you need to resolve some ambiguity. Commonly you can just call the method.Changes necessary as obvious from the shown excerpt:
getOneIntersectingObject()isMarker.class, because you seem to want this.if. If you don't remove it: This semicolon is an empty statement, so theifwill have no effect. The block between the braces following it will always be executed.boneasmarkerto show your intention. (It would "shadow" the "outer"bone, additionally, but this is no problem here.)addObject()with the right parameters: the object to place (the new marker), and its coordinates (retrieved by callinggetX()andgetY()).