This site requires JavaScript, please enable it in your browser!
Greenfoot back
tylers
tylers wrote ...

2012/5/23

scale

tylers tylers

2012/5/23

#
why does a little circle i make turn into a square. here is the code:
import greenfoot.*;  // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)

/**
 * Write a description of class pop here.
 * 
 * @author (your name) 
 * @version (a version number or a date)
 */
public class pop extends Actor
{
    int size = 0;
    int sX = 10;
    int sY = 10;
    public pop()
    {
        //getImage().scale(sX,sY);
    }

    /**
     * Act - do whatever the pop wants to do. This method is called whenever
     * the 'Act' or 'Run' button gets pressed in the environment.
     */
    public void act() 
    {
        if (size <=20)
        {
            
            sX++;
            sY++;
            size ++;
            
            getImage().scale(sX,sY);
        }

    }    
}
im trying to make the circle bigger and the circle was made in gimp.
danpost danpost

2012/5/23

#
Each time the act method is called, you end up scaling a scaled image. The result in doing this is what you see happening. What you need to do, is create a new GreenfootImage by using one of its constructors (probably the one that uses the filename, since you made it in gimp), and scale that new image directly to the required size.
You need to login to post a reply.