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

2018/10/30

Is there a way to wait before each while iteration?

benig benig

2018/10/30

#
if(images == null) 
        {
            GreenfootImage baseImage = new GreenfootImage("wave.png");
            images = new GreenfootImage[NUMBER_IMAGES];
            int i = 0;
            while (i < NUMBER_IMAGES) 
            {
                int size = (i+1) * ( baseImage.getWidth() / NUMBER_IMAGES );
                images[i] = new GreenfootImage(baseImage);
                images[i].scale(size, size);
                i++;
            }
        }
Is there a way to wait before each while iteration? For example, wait for a few microseconds?
danpost danpost

2018/10/30

#
benig wrote...
Is there a way to wait before each while iteration? For example, wait for a few microseconds?
Add:
Greenfoot.delay(1);
within the while loop. That should be good for around 20 milliseconds.
You need to login to post a reply.