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

2018/1/27

Sidescrolling jerky background scroll

Paul12345 Paul12345

2018/1/27

#
I'm using this sidescroller demo in my project Scrolling . The thing is my world is 1500 by 600 pixels and the background scrolls jerky , rocking back and forth pretty noticeable any way to fix it? And it doesn't seem to lag the whole scenario , the characters move smoothly at all times and if the background is set to white the background scrolls also smoothly it's only a problem with the detailed background.
danpost danpost

2018/1/27

#
I am sure that when the background is set to white that it will still be jerky -- it just is not noticeable. You will need to show your ScrollingWorld subclass code for evaluation.
Paul12345 Paul12345

2018/1/27

#
import greenfoot.*;  // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)

/**
 * Write a description of class Nivel0 here.
 * 
 * @author (your name) 
 * @version (a version number or a date)
 */
public class Nivel0 extends SWorld
{

    /**
     * Constructor for objects of class Nivel0.
     * 
     */
    public Nivel0()
    {
        super(1500,600, 1,3000);
        setMainActor(new Elev(), 40, 40);
        mainActor.setLocation(100, 30);
        GreenfootImage bg = new GreenfootImage("cyberpunk-street-Scroll.png");
        setScrollingBackground(bg);
        prepare();

    }

    private void prepare()
    {

        Platforma platforma = new Platforma(300);
        addObject(platforma,376,522);
        platforma.setLocation(398,535);
        AI ai = new AI();
        addObject(ai,659,525);
        Platforma platforma2 = new Platforma(300);
        addObject(platforma2,895,471);
        platforma2.setLocation(903,426);
        Cutie cutie = new Cutie(40, 40);
        addObject(cutie,395,337);
        platforma2.setLocation(745,514);
        Cutie cutie2 = new Cutie(40, 40);
        addObject(cutie2,349*2/3,343*2/3);
        ViataPickup viatapickup = new ViataPickup(20, 20);
        addObject(viatapickup,609,550);
        Tutorial0 tutorial0 = new Tutorial0(30, 30);
        addObject(tutorial0,403,498);
    }


    public void RestartNivel()
    {
        Greenfoot.setWorld(new Nivel0());
    }

    public void NivelUrmator()
    {
        Greenfoot.setWorld(new Nivel1());
    }
}
Paul12345 Paul12345

2018/1/27

#
and from the SWorld i didn't modify anything
danpost danpost

2018/1/27

#
It looks like everything in the SWorld subclass was done correctly. It would be difficult to determine the cause without working directly with your project. This scrolling class was my original one (kind of a dinosaur -- big and bulky). My suggestion is that you try using my Scroller class which is discussed in my Scrolling Tutorial scenario and used in my Scroller Class Demos scenario.
Paul12345 Paul12345

2018/1/27

#
I will try . Thank you for helping !
You need to login to post a reply.