Hello,
I'm working on a basic particle system. However, I have 3 images .png images (star, diamond, circle) and they are all white. I want this image to get a random number to generate a new color.
Here is the code used right now:
The images still appear as white. Is there a way to let Greenfoot overwrite the colors of a imported image?
Thanks!
import greenfoot.*; import java.awt.Color; public class cParticle extends cParticleSystem { int dirX; int dirY; int Power; int Life; public cParticle(int X, int Y, int power, int color, int life) { int imgNum = (Greenfoot.getRandomNumber(3) + 1); GreenfootImage display = new GreenfootImage("particle_" + imgNum + ".png"); display.setColor(new Color(color, color, color)); setImage(display); dirX = X; dirY = Y; Power = power; Life = life; } public void act() { setLocation(getX() + dirX + (Power), getY() + dirY + (Power)); update(); } public void update() { if (Life > 5) { Life--; if (Power > 0) { Power--; } getImage().setTransparency(Life); } } }