Im trying to make it so that the Laser spawn periodically on the Ship. I almost have it down, but for some reason it keeps saying getX() and getY() are undeclared methods and idk how to fix it.
Here is my current code:
public class Space extends World
{
private int spawnTimer;
private void checkForSpawning()
{
spawnTimer = (spawnTimer+1)%200;
if (spawnTimer == 0)
{
addObject(new Laser(),getObjects(Ship.class).getX(), getObjects(Ship.class).getY()-10);
}
}
public Space()
{
// Create a new world with 600x400 cells with a cell size of 1x1 pixels.
super(600, 400, 1);
prepare();
}
private void prepare()
{
Ship ship = new Ship();
addObject(ship,320,194);
ship.setLocation(321,219);
ship.setLocation(313,293);
}
}

