As in the title, I'm trying to add an object but the addObject method isn't working for some reason, not sure what I've done to accomplish that lol. I'm trying check if the 'hollowTurtle' is touching an object 'car' and if it is then despawn but if it isn't then spawn a 'turtle' at the location of the object 'hollowTurtle' and then remove the 'hollowTurtle'. Thank you for your time!
public class hollowTurtle extends Actor
{
/**
* Act - do whatever the turtle wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
public void act()
{
// Add your action code here.
spawnTurtle();
}
public void spawnTurtle()
{
if (isTouching(car.class))
{
getWorld().removeObject(this);
}
else
{
int turtleX = getX();
int turtleY = getY();
addObject(new turtle(), turtleX, turtleY);
getWorld().removeObject(this);
}
}
}
