Hi! I've run into a problem again!
When I hover over the red line it appears with this:
method getWorld in class greenfoot.Actor cannot be applied to given types:
required: no arguments
found: rock
reason: actual and formal argument lists differ in length
Here's the code:
Sorry to keep asking for help! :( But, any assistance would be greatly appreciated! Thank you!
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
/**
* Write a description of class rock here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class rock extends AnimBase
{
/**
* Act - do whatever the rock wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
int speed = 2;
public void act()
{
move();
checkCollision();
checkCollisionBoundary();
}
public void move(){
int y = getY();
setLocation(getX(),y+speed);
}
private void checkForBorder()
{
World world = getWorld();
int y = world.getHeight();
if(getY()==y){
getWorld().removeObject(this);
}
}
private void checkCollisionBoundary(){
int y = getY();
int maxy = getWorld().getHeight()-1;
if(getWorld(this)==null){
if(y==maxy){
getWorld().removeObject(this);
}
}
}
private void checkCollision(){
World world;
world=getWorld();
Object obj=world.getObjects(Ship.class).get(0);
Ship ship=(Ship) obj;
int shipX=ship.getX();
int shipY=ship.getY();
Actor topLeftShip = getOneObjectAtOffset(shipX/-2,shipY/2,Ship.class);
Actor topRightShip = getOneObjectAtOffset(shipX/2,shipY/2,Ship.class);
if(topLeftShip != null || topRightShip != null){
world.removeObject(this);
}
}
}
