I want to port my game to android so i create a button so when it get pressed it will move bee object.
import greenfoot.*;
public class Level1 extends World
{
/**
* Constructor for objects of class Level1.
*
*/
public Level1()
{
// Create a new world with 600x400 cells with a cell size of 1x1 pixels.
super(600, 400, 1);
prepare();
}
/**
* Prepare the world for the start of the program. That is: create the initial
* objects and add them to the world.
*/
private void prepare()
{
Bee bee = new Bee();
addObject(bee, 148, 191);
Button button = new Button();
addObject(button, 336, 326);
}
}
public void act()
{
if (Greenfoot.mouseClicked(button))
{
bee.move();
}
}