int backgroundPosition = 0
int moveAmount = how many pixels you want it to move
GreenfootImage yourBackgroundImage = your background image
public void act()
{
backgroundPosition -= moveAmount;
getWorld().getBackground().drawImage(yourBackgroundImage, backGroundPosition, 0);
}
can you do me a favor and go here http://www.greenfoot.org/scenarios/8396 and set a high score so i can make sure its working
that will scroll the screen
let assume you've got the player running saved as 7 image named run 1-7 all .png format
this would go in your player class
int runNo = 0;
String run = { "run1.png", "run2.png", "run3.png", "run4.png", "run5.png", "run6.png", "run7.png" };
public void act()
{
setImage(runR);
runNo++;
if(runNo > 6) { runNo = 0; }
}
so the whole thing would be
int runNo = 0;
int backgroundPosition = 0 int moveAmount = how many pixels you want it to move GreenfootImage yourBackgroundImage = your background image
String run = { "run1.png", "run2.png", "run3.png", "run4.png", "run5.png", "run6.png", "run7.png" };
public void act()
{
backgroundPosition -= moveAmount;
getWorld().getBackground().drawImage(yourBackgroundImage, backGroundPosition, 0);
setImage(runR);
runNo++;
if(runNo > 6) { runNo = 0; }
}
put that in your player class get the images for the player running
remember for "if(runNo > 6) { runNo = 0; }" the 6 should be the number of images - 1
thats supposed to say run. it's a reference to
String run = { "run1.png", "run2.png", "run3.png", "run4.png", "run5.png", "run6.png", "run7.png" };
if u want any more help with this need 2 download java and set a score on my game
int runNo = 0;
int backgroundPosition = 0;
int moveAmount = 5;
GreenfootImage yourBackgroundImage = your background image;
String run = { "Run1.png", "Run2.png", "Run3.png", "Run4.png", "Run5.png", "Run6.png");
public void act()
{
backgroundPosition -= moveAmount;
getWorld().getBackground().drawImage(yourBackgroundImage, backGroundPosition, 0);
setImage(runR);
runNo++;
if(runNo > 5) { runNo = 0; }
}
I have that in there but It's not working do replace yourBackground image with something?