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

2013/4/20

How to make an image larger

1
2
3
4
danpost danpost

2013/4/21

#
In mine, remove the first 'setColor' and 'fill' lines. In yours, as far as I can tell, there is no back color.
JetLennit JetLennit

2013/4/21

#
Fixed it, and but how do i make it get bigger quicker?
danpost danpost

2013/4/21

#
Increase the factor (1.1).
JetLennit JetLennit

2013/4/21

#
Take a look at this now there are some other problems like a sudden vanishing
danpost danpost

2013/4/21

#
I cannot read the second verse.
JetLennit JetLennit

2013/4/21

#
Sorry about that
Game/maniac Game/maniac

2013/4/21

#
Coming code:
import greenfoot.*;  // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
import java.awt.Color; 
/**
 * Write a description of class Coming here.
 * 
 * @author (your name) 
 * @version (a version number or a date)
 */
public class Coming extends Actor
{
    private int width;
    private int height;
    private boolean turning;
    GreenfootImage baseImage; // the base image that gets scaled
    int percentage = 10; // percentage amount to scale base image by
    boolean xRegistered = false;
    double exactX;
    int amount;
    public Coming()
    {
        baseImage = getImage();
        updateImage(); // initializing image of actor
    }
    /**
     * Act - do whatever the Coming wants to do. This method is called whenever
     * the 'Act' or 'Run' button gets pressed in the environment.
     */
    public void act() 
    {
        if(!xRegistered){
            exactX=getX();
            xRegistered=true;
            amount = (int)exactX-250;
        }else{
            updateImage();
        }
        exactX+=amount/7;
        setLocation((int)exactX, getY() + 7);
        percentage = (int)((double)percentage + 10);
        if(getY() > 180) getWorld().removeObject(this);
    }    
    private void updateImage()
    {
        GreenfootImage image = new GreenfootImage(baseImage);
        image.scale(image.getWidth()*percentage/100, image.getHeight()*percentage/100);
        setImage(image);
    }
}
Game/maniac Game/maniac

2013/4/21

#
the chickens also go along the road now giving a better 3D effect
Game/maniac Game/maniac

2013/4/21

#
I also change links code a bit:
import greenfoot.*;  // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)

/**
 * Write a description of class Link here.
 * 
 * @author (your name) 
 * @version (a version number or a date)
 */
public class Link extends Actor
{
    /**
     * Act - do whatever the Link wants to do. This method is called whenever
     * the 'Act' or 'Run' button gets pressed in the environment.
     */
    public void act() 
    {
        if(Greenfoot.isKeyDown("left"))
        {
            setImage("LinkKartLeft.png");
            setLocation(getX()-8, getY());
        }
        else if(Greenfoot.isKeyDown("right"))
        {
            setImage("LinkKartRight.png");
            setLocation(getX()+8, getY());
        }
        else setImage("LinkKartBack.png");
        Coming coming = (Coming)getOneIntersectingObject(Coming.class);
        if(coming != null && coming.getY()>getY()-5)
            getWorld().removeObject(this);
    }    
}
Game/maniac Game/maniac

2013/4/21

#
And fixed the spawning method:
public void comings()
{
    Coming coming = new Coming();
    addObject(coming, Greenfoot.getRandomNumber(90) + 205, 2);
}
JetLennit JetLennit

2013/4/21

#
How do i change the Coming code to make it get bigger faster and have it move on x more?
Game/maniac Game/maniac

2013/4/21

#
On line 37 change 7 to a lower number to make it move more out wards, and on line 39 change 10 to a larger number to make it enlarge quicker
Game/maniac Game/maniac

2013/4/21

#
You might also want to change the spawn code again to something like this:
public void comings()  
{  
    Coming coming = new Coming();  
    addObject(coming, Greenfoot.getRandomNumber(51) + 220, 2);  
}  
JetLennit JetLennit

2013/4/21

#
But now the world is way different
Game/maniac Game/maniac

2013/4/21

#
I know thats why I said you should use that
There are more replies on the next page.
1
2
3
4