The is a 'scale' method in the GreenfootImage class. See the documentation. Be aware the multiple scaling can distort an image (that is to say, in general, only scale an image once).
its says error when i put in the code and i don't know where to put it in this:
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
/**
* Write a description of class Bullet here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class Bullet extends Animal
{
/**
* Act - do whatever the Bullet wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
public void act()
{
setLocation(getX() + speed, getY());
checkBoundaries();
destroyEnemies();
}
public void checkBoundaries()
{
if(getX() > getWorld().getWidth() - 1)
getWorld().removeObject(this);
else if(getX() < 1)
getWorld().removeObject(this);
if(getY() > getWorld().getHeight() - 1)
getWorld().removeObject(this);
else if(getY() < 1)
getWorld().removeObject(this);
}
public void destroyEnemies()
{
//"Enemy" can be any class that you want the bullet to destroy.
Actor enemy = getOneIntersectingObject(player.class);
if(enemy != null) {
getWorld().removeObject(enemy);
getWorld().removeObject(this);
}
}
private int speed = 10;
}