Hi,
I have 2 classes which this question relates to: frames and hero. I want to stop the hero from moving when the frame is shown on the screen. so far I have this for the frames class:
In the act method of the Hero I have this but not sure where I have gone wrong retuning if frameActive value. The code is as follows:
Any suggestions?
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
/**
* Write a description of class Message here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class Frames extends Tiles
{
public boolean frameActive;
public Frames(String selection)
{
this.selection = selection;
this.directory = "Frames/";
this.frameActive = true;
if (selection == "type1")
setImage(directory + "type1.png");
else if (selection == "type2")
setImage(directory + "type2.png");
}
public void act()
{
if (getWorld().getObjects(Text.class).size() == 0 && Greenfoot.isKeyDown("enter"))
{
this.frameActive = false;
getWorld().removeObject(this);
}
}
public boolean getFrameActive()
{
return frameActive;
}
} public void act()
{
if (((Frames) getWorld().getObjects(Frames.class).get(0)).getFrameActive() == false)
{
checkKeys();
}
mapSpecificBoundaries();
}
