Hi, so i have a boat class, and in a different class (Victor class) I'm trying to delete the boat, and also I need to bring back the boat at a later time. i know I have to make it into an object, but I'm not sure how to do that.
getWorld().removeObjects(getWorld().getObjects(Boat.class));
getWorld().addObject(new Boat(), /* new location coordinates */);
// add instance field to Victor class
private Boat boatRemoved = null;
// to save boat being removed
if (getX() > 1800 && boatRemoved == null)
{
boatRemoved = (Boat)getWorld().getObjects(Boat.class).get(0);
getWorld().removeObject(boatRemoved);
}
// and add back into the world later with
if (boatRemoved != null)
{
getWorld().addObject(boatRemoved, /* new location coordinates */);
boatRemoved = null;
}