I am making a game where you control a bee and when you press the up key a butterfly apears to wherever the bee is. but it doesn't know the method Greenfoot.getX() or Greenfoot.getY(). Here is my code;
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
/**
* Write a description of class bee here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class bee extends Actor
{
/**
* Act - do whatever the bee wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
public void act()
{
move(4);
if (Greenfoot.isKeyDown ("left"))
{
turn(-4);
}
if (Greenfoot.isKeyDown ("right"))
{
turn(4);
}
if (Greenfoot.isKeyDown ("up"))
{
World world;
world = getWorld();
world.addObject (new butterfly(), Greenfoot.getX(), Greenfoot.getY());
}
}
}

