I am not sure what type of this asking it should be. But most importantly, it is about Greenfoot system that appears to be a trouble.
I am scaling an image in an actor.
this actor does expand the size of the image, then shrink again.
Now, I have added the actor to the World.
there.
The problem is:
After the image being reffered shrunk, the quality ruins!
Before Act:
After Act:
image size shrinking:
Sorry for large images. Basically, I simply scale and update the set image with the new setting reffered.
I must have used the scaler wrongly.
If you have any solution to make the image does not broke with scaling, feel free and thanks for your help.
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
/**
* Write a description of class BoomImage here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class BoomImage extends ExplosionImage
{
private boolean existed = false;
private int Sequence = 0;
private int [] DynaSize = new int[] {0,0};
private int DynaX = 0;
private int DynaY = 0;
private int [] Ukuran = new int[]{getImage().getWidth(), getImage().getHeight()};
private int nonDeltaTimeKey = 100;
private GreenfootImage baseImg = new GreenfootImage("BoomImage.png");
private GreenfootImage imaging = new GreenfootImage(baseImg);
public BoomImage(){
DynaSize[0] = 1;
DynaSize[1] = 1;
imaging.scale(Ukuran[0], Ukuran[1]);
setImage(imaging);
//existed = true;
}
public void addedToWorld(World world){
existed = true;
Sequence = 0;
}
/**
* Act - do whatever the ExplosionImage wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
public void act()
{
// Add your action code here.
//DynaSize[0] += 10;
//DynaSize[1] += 10;
//imaging.scale(DynaSize[0], DynaSize[1]);
//setImage(imaging);
if(existed == true){
if(Sequence == 0){
if(DynaSize[0] < Ukuran[0] || DynaSize[1] < Ukuran[1]){
DynaSize[0] += 10;
DynaSize[1] += 10;
} else if(DynaSize[0] >= Ukuran[0] || DynaSize[1] > Ukuran[1]){
Sequence = 1;
}
} else if(Sequence == 1){
if(DynaSize[0] > 2 || DynaSize[1] > 2){
DynaSize[0] -= 10;
DynaSize[1] -= 10;
} else if(DynaSize[0] <= 2 || DynaSize[1] <= 2){
imaging.setTransparency(0);
Sequence = 2;
}
}
imaging.scale(DynaSize[0], DynaSize[1]);
setImage(imaging);
}
}
}
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
/**
* Write a description of class testResult2 here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class testResult2 extends testAreas
{
/**
* Constructor for objects of class testResult2.
*
*/
public testResult2()
{
prepare();
}
/**
* Prepare the world for the start of the program.
* That is: create the initial objects and add them to the world.
*/
private void prepare()
{
levelNumber levelnumber = new levelNumber(12, "Windowsl");
addObject(levelnumber,getWidth()/2,12);
DuarImage duarimage = new DuarImage();
addObject(duarimage,255,202);
BoomImage boomimage = new BoomImage();
addObject(boomimage,446,202);
}
}
image size shrinking:
Sorry for large images. Basically, I simply scale and update the set image with the new setting reffered.
I must have used the scaler wrongly.
If you have any solution to make the image does not broke with scaling, feel free and thanks for your help.

