Hi,
Ive created a Rectangle class:
In my world class I am using this to create a block of rectangles:
How do I get each of the small rectangles to fade out line by line instead of all together?
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
import java.awt.Color;
/**
* Write a description of class Misc here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class Rectangle extends Tiles
{
int timer;
public Rectangle(int countDown)
{
GreenfootImage LittleRectangle = new GreenfootImage(8, 14);
LittleRectangle.setColor(new Color(0, 0, 0));
LittleRectangle.fillRect(0, 0, 8, 14);
setImage(LittleRectangle);
LittleRectangle.setTransparency(255);
this.speed = 1;
timer = countDown;
}
/**
* Act - do whatever the Misc wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
public void act()
{
animationCounter ++;
timer--;
if (timer <= 0)
{
fadeOut();
}
}
public void fadeOut()
{
GreenfootImage Transition = getImage();
Transition.setTransparency(Transition.getTransparency() - speed);
animationCounter++;
if(Transition.getTransparency() <= 5)
{
getWorld().removeObject(this);
}
}
}
public void addRectangles()
{
for(int i=29 ; i<425 ; i+=8) {
for(int j=282 ; j <= 340 ; j += 14) {
addObject(new Rectangle(i + 25), i, j);
}
}
}