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

2019/12/1

Trouble with background

1
2
3
Al3x7373 Al3x7373

2019/12/3

#
danpost wrote...
Al3x7373 wrote...
That's probably the problem both the private int High / private int Wide have no fields
They ARE fields -- and they have values.
It must be 900 for wide and 540 for High if i remember right
danpost danpost

2019/12/3

#
Al3x7373 wrote...
It must be 900 for wide and 540 for High if i remember right
Let's try a different way. What are the dimensions of your "Unknown.jpeg" image?
Al3x7373 Al3x7373

2019/12/3

#
danpost wrote...
Al3x7373 wrote...
It must be 900 for wide and 540 for High if i remember right
Let's try a different way. What are the dimensions of your "Unknown.jpeg" image?
251x200
danpost danpost

2019/12/3

#
Al3x7373 wrote...
danpost wrote...
Al3x7373 wrote...
It must be 900 for wide and 540 for High if i remember right
Let's try a different way. What are the dimensions of your "Unknown.jpeg" image?
251x200
Really ??? No wonder it won't scroll !!! In your Sky constructor, adjust to the following:
int bgWide = 1200;
int bgHigh = 540;
Al3x7373 Al3x7373

2019/12/3

#
danpost wrote...
Al3x7373 wrote...
danpost wrote...
Al3x7373 wrote...
It must be 900 for wide and 540 for High if i remember right
Let's try a different way. What are the dimensions of your "Unknown.jpeg" image?
251x200
Really ??? No wonder it won't scroll !!! In your Sky constructor, adjust to the following:
int bgWide = 1200;
int bgHigh = 540;
I did it but it didn't change anything
Al3x7373 Al3x7373

2019/12/3

#
Al3x7373 wrote...
danpost wrote...
Al3x7373 wrote...
danpost wrote...
Al3x7373 wrote...
It must be 900 for wide and 540 for High if i remember right
Let's try a different way. What are the dimensions of your "Unknown.jpeg" image?
251x200
Really ??? No wonder it won't scroll !!! In your Sky constructor, adjust to the following:
int bgWide = 1200;
int bgHigh = 540;
I did it but it didn't change anything
public class Sky extends World { int bgWide = 1200; int bgHigh = 540; public static final int WIDE = 930; public static final int HIGH =540; public static final int CELL =1; Scroller scroller; Actor Megaman; public Sky() { super( WIDE, HIGH, CELL, false); GreenfootImage bg = new GreenfootImage("Unknown.jpeg"); int bgWide = bg.getWidth(); int bgHigh = bg.getHeight(); scroller = new Scroller(this, bg, bgWide, bgHigh); Megaman = new Megaman(); addObject(Megaman, bgWide/2, bgHigh/2); scroll(); Spawn(); } public void act() { if (Megaman != null && Megaman.getWorld() == this) scroll(); } private void scroll() { int dsx = Megaman.getX()-WIDE/2; int dsy = Megaman.getY()-HIGH/2; scroller.scroll(dsx, dsy); } That's my code if it helps u spot the problem
danpost danpost

2019/12/3

#
Remove those two lines you just added. Below in 'public Sky()', modify these lines:
int bgWide = bg.getWidth();
int bgHigh = bg.getHeight();
You need to login to post a reply.
1
2
3