My circle is becoming a square when scaling the image. I dont know why please help me :)
Here is the code of my main actor:
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
import java.util.Random;
/**
* Write a description of class Blob here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class Blob extends Actor
{
/**
* Act - do whatever the Blob wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
int x;
int y;
int i;
int size = 10;
int blobIndex = 0;
int maxBlobs = 20;
BlobFood blobFood = new BlobFood;
Color initial = new Color(Greenfoot.getRandomNumber(255), Greenfoot.getRandomNumber(255), Greenfoot.getRandomNumber(255), Greenfoot.getRandomNumber(255));
GreenfootImage img = new GreenfootImage(size, size);
public int getBlobIndex(){
return blobIndex;
}
public int getMaxBlobs(){
return maxBlobs;
}
public void addBlob(){
if(maxBlobs > blobIndex){
blobFood = new BlobFood();
getWorld().addObject(blobFood,Greenfoot.getRandomNumber(255),Greenfoot.getRandomNumber(255));
blobFood.setImage(blobFood.setShape());
blobIndex += 1;
}
}
public GreenfootImage setShape(){
img.setColor(initial);
img.fillOval(0, 0,size,size);
return img;
}
public void eat(){
if(getObjectsInRange(size, BlobFood.class).size() > 0)
{
getWorld().removeObjects(getObjectsInRange(size, BlobFood.class));
size += 2;
getImage().scale(size, size);
}
}
public void movement(){
int x = getX();
int y = getY();
if (Greenfoot.isKeyDown("left")){
x -= 1;
setLocation(x,y);
}
if (Greenfoot.isKeyDown("right")){
x += 1;
setLocation(x,y);
}
if (Greenfoot.isKeyDown("up")){
y -= 1;
setLocation(x,y);
}
if (Greenfoot.isKeyDown("down")){
y += 1;
setLocation(x,y);
}
}
public void act()
{
movement();
eat();
}
}
