I'm trying to make a health thing for my game. When I try to compile it says "bad operand types for binary "*"" Also "first type greenfoot.GreenfootImage; second type int." here's the code
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
import java.awt.Color;
/**
* Write a description of class Health here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class Health extends Actor
{
int health = 100;
/**
* Act - do whatever the Health wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
public void act()
{
setImage(new GreenfootImage (82, 17));
GreenfootImage health = getImage();
health.setColor(Color.WHITE);
health.drawRect(0, 0, 81, 16);
health.setColor(Color.RED);
int rectWidth = health * 1;
health.fillRect(1, 1, rectWidth, 15);
}
}
