i have 7 bad classes. Each one of them runs in different ways. Everyone is removed, as soon as they touch the bomb.class. When they do touch, the animation of adding the smokeBomb will occur.
Bad.class
Bad1.class
I also created the badGeral, where it would be supposed to put the methods, so I could just call them in each bad class. Problem is, I'm not having access to it, and I don't know why!
I can't access the move() method, neither the moveBad() method..
badGeral().class
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
public class Bad extends badGeral
{
public static int PASSO = 1;
private int dirX;
private int dirY;
private int contadorBad = 0;
//Construtor de inicialização
public Bad()
{
// image1 = new GreenfootImage("bad.png");
// image2 = new GreenfootImage("bad1.png");
// image3 = new GreenfootImage("bad2.png");
// image4 = new GreenfootImage("bad3.png");
setImage(image1);
dirX = 0;
dirY = 1;
}
/**
* Act - do whatever the bad wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
public void act()
{
contadorBad++;
moveBad();
if(contadorBad == velocidade)
{
move();
switchImage();
contadorBad = 0;
}
}
//Muda de direção
public void moveBad()
{
if(getY() == 28 && dirY == 1)
{
dirY = -1;
}
if(getY() == 1 && dirY == -1)
{
dirY = 1;
}
}
public void move()
{
setLocation(getX() + PASSO * dirX, getY() + PASSO * dirY);
}
}
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
/**
* Write a description of class bad1 here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class Bad1 extends badGeral
{
private static int PASSO = 1;
private int dirX;
private int dirY;
private int contadorBad = 0;
//Sequencia de imagens para sensação de movimento do Bad
public Bad1()
{
// image1 = new GreenfootImage("bad.png");
// image2 = new GreenfootImage("bad1.png");
// image3 = new GreenfootImage("bad2.png");
// image4 = new GreenfootImage("bad3.png");
setImage(image1);
dirX = 1;
dirY = 0;
}
/**
* Act - do whatever the bad1 wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
public void act()
{
contadorBad++;
moveBad();
if(contadorBad == 3)
{
move();
switchImage();
contadorBad = 0;
}
}
//muda de direção
public void moveBad()
{
if(getX() == 28 && dirX == 1)
{
dirX = -1;
}
if(getX() == 1 && dirX == -1)
{
dirX = 1;
}
}
public void move()
{
setLocation(getX() + PASSO * dirX, getY() + PASSO * dirY);
}
}
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
public class badGeral extends pacActors
{
public static final GreenfootImage image1 = new GreenfootImage("bad.png");
public static final GreenfootImage image2 = new GreenfootImage("bad1.png");
public static final GreenfootImage image3 = new GreenfootImage("bad2.png");
public static final GreenfootImage image4 = new GreenfootImage("bad3.png");
public int velocidade = 3;
public int dirX;
public int dirY;
public static int PASSO = 1;
/**
* Act - do whatever the badGeral wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
public void act()
{
}
public void switchImage()
{
if(getImage() == image1)
{
setImage(image2);
}
else
if(getImage() == image2)
{
setImage(image3);
}
else
if(getImage() == image3)
{
setImage(image4);
}
else
if(getImage() == image4)
{
setImage(image1);
}
}
// public void moveBad()
// {
// if(getY() == 28 && dirY == 1)
// {
// dirY = -1;
// }
//
// if(getY() == 1 && dirY == -1)
// {
// dirY = 1;
// }
// }
}
