Hi, i'm working on a game, inspired by Subway Surfers. Now i'm trying to make it look like the obstacles come closer to you, I tried to do this by moving the actor while scaling up the image. But it doesn't work like I hoped it would. Instead it makes the image totaly different by (I guess) just adding pixels in the middle.
edit: what I descriped above is from a previous code I've tried. Now Greenfoot just stops if a car spawns in. (they do or don't spawn in based on a random generated number, every 0,5 sec)
This is the code:
I hope someone can help me out!
public auto()
{
GreenfootImage image = getImage();
image.scale(86, 52);
}
/**
* Act - do whatever the auto wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
public void act()
{
setLocation(getX() - 1, getY() + 2); //move the car
double X = (getY()/(52/30)); //make a variable based on the Y-value and the ratio it must be scaled up by
double Y = (getY()/(86/30));
int A = (int) X;
int B = (int) Y;
GreenfootImage image = new GreenfootImage("auto.jpeg");
image.scale(A, B);
setImage(image);
if (isAtEdge()) {
getWorld().removeObjects(getWorld().getObjects(auto.class));
}
}
