public void act()
{
//ruby movement
setImage (Gif.getCurrentImage());
setLocation(getX()-3, getY());
DeleteAtEdge();
AddRubies();
}
//deletes ruby if at edge
public void DeleteAtEdge()
{
if(isAtEdge())
{
World world;
world = getWorld();
world.removeObject(this);
}
}
//Ninja collects ruby after making contact
//increases scoreboard by "1" after every collected Ruby
public void AddRubies() {
Actor Ninja;
Ninja = getOneObjectAtOffset(0,0,Ninja.class);
if (Ninja != null)
{
World world;
world = getWorld();
world.removeObject(this);
RubyCount++;
}
}
}
I receive this error everytime I run my code: Actor not in world. An attempt was made to use the actor's location while it is not in the world. Either it has not yet been inserted, or it has been removed. I'm not able to spawn a coin in game and have it deleted on screen.

