I've got a problem with using the 'Beam' Class.
The beam is meant to turn wherever the actor is facing but I'm not getting this result.
This is the Lamp Code (Simple enough).
This is the World as a whole's code. (In short, the World Code spawns the Beam and Actor, what I presume, correctly).
public class Lamp extends Actor
{
int dir = 0;
/**
* Act - do whatever the Lamp wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
public void act()
{
setRotation(90);
}
}public class Level1 extends World
{
GifImage gif = new GifImage("Level1.gif");
boolean colored = false;
int size;
GreenfootImage darkness;
/**
* 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();
}
public void act()
{
setBackground(gif.getCurrentImage());
if(getObjects(Beam.class).isEmpty()) return;
Beam beam=(Beam)getObjects(Beam.class).get(0);
}
/**
* Prepare the world for the start of the program.
* That is: create the initial objects and add them to the world.
*/
private void prepare()
{
Wreckage wreckage = new Wreckage();
addObject(wreckage,350,295);
wreckage.setLocation(323,279);
Lamp lamp = new Lamp();
}
}
