I'm making a game that essentially is a target practice game, with a target board, a gun, and bullethole objects. When trying to make my bullets move relative to the target board after being placed down, the compiler gives me an error that says the target board actor isn't in the world\\\
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
/**
* Write a description of class bullethole here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class bullethole extends Actor
{
int x = 0;
int y = 0;
int xb = 0;
int yb = 0;
int xa = 0;
int ya = 0;
int timer = 0;
TargetBoard target = new TargetBoard();
/**
* Act - do whatever the bullethole wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
public void act()
{
if(isTouching(TargetBoard.class))
{
x = target.getX();
y = target.getY();
xa = getX();
ya = getY();
xb = x - xa;
yb = y - ya;
setLocation( getX() + xb, getY() + yb);
}
timer++;
}
}
