mport greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
/**
* Write a description of class KnightSpawnButton here.
*
* @author ( BradH)
* @version (a version number or a date)
*/
public class KnightSpawnButton extends GoodTroops
{private Counter counter;
public KnightSpawnButton(Counter pointCounter)
{
counter = pointCounter;
}
/**
* Act - do whatever the KnightSpawnButton wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
public void act()
{click();
no();
nospawn();
}
public void click()
{
getWorld().addObject(new Knight1(), 45 , 306);
if (Greenfoot.mouseClicked(this))
Greenfoot.playSound("swordspawn1.wav");
if (Greenfoot.mouseClicked(this))
counter.subtract(2);
}
//if counter < 2 call on no spawn method
public void no()
{
(counter.getValue() < 2){
nospawn)();
}
}
//if mouse is clicked do nothing
public void nospawn()
{
if (Greenfoot.mouseClicked(this))
}
I need to put in a line of code in my nospawn method that would allow the Actor to spawn nothing if the counter is less than 2, any ideas?

