This site requires JavaScript, please enable it in your browser!
Greenfoot back
qsapp.3
qsapp.3 wrote ...

2013/7/10

I have Enemy 1, 2 and 3 but Enemy 2 is compiled perfectly but the other 2 say they r compiled but still have the lines and wont let me place them on the map. what am i doing wrong?? here is Enemy1

qsapp.3 qsapp.3

2013/7/10

#
import greenfoot.*;  // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)

/**
 * Write a description of class Enemy here.
 * 
 * @author (Quinn Sapp) 
 * @version (5 July 2013)
 */
public class Enemy extends Animal
{
  /**
     * Act - do whatever the Enemy wants to do. This method is called whenever
     * the 'Act' or 'Run' button gets pressed in the environment.
     */
	public void act()
	{
    	move(3);
    	turnAtEdge();
    	randomTurn();
    	tryToEatMainPlayer();
	}
	public void turnAtEdge(){
    	if (atWorldEdge()){
    	turn(17);
	}//end if    
  }
   public void randomTurn() {
 	if (Greenfoot.getRandomNumber(100)<10)
	{
    	turn(5);
	}//end if
  }
	public void tryToEatMainPlayer(){
	if(canSee(MainPlayer.class)){
    	eat(MainPlayer.class);
    	Greenfoot.playSound("au.wav");
    }
  }
}
danpost danpost

2013/7/10

#
In order to manually place them on the map, they must have a constructor method in the class. For the class given above, add this constructor:
public Enemy()
{
}
You need to login to post a reply.