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

2013/1/9

How to make the ground keep scrolling?

AnneMacaroni AnneMacaroni

2013/1/9

#
I don't want to make a scrolling background b/c it's too confusing so I decided to make a scrolling ground, which is an object, to make it look like my actor is moving. How would I make it so that the ground (Ground.class) could keep remaking itself? However I want it so that there are gaps in between so the actor can jump over the gap. Please help. I tried many ways but it lags a lot b/c I used counters and the counter eventually got to big (greater than 2000....)
public void createContinualPlatform()
    {
        counter++;

        if (counter > 500 && counter <= 600)
        {
            grassPlain = new GrassPlain();
            addObject(grassPlain, 800, 230);
        }

        if (counter > 600)
        {
            counterNext++;
            
            if (counterNext > 30 && counterNext <= 200)
            {
                grassPlain = new GrassPlain();
                addObject(grassPlain, 800, 384);
            }
            if (counterNext > 230 && counterNext <= 350)
            {
                grassPlain = new GrassPlain();
                addObject(grassPlain, 800, 230);
                if (counterNext == 350)
                    counterNext = 0;
            }
        }
    }
I then called it in the world's act() method so that this would keep repeating itself. Anyway to make it better? or provide a scenario that has a scrolling object (ground)
You need to login to post a reply.