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

2011/5/31

Slow Run Time: Games with over 50MB

RockSmash RockSmash

2011/5/31

#
I am making a game with over 50MB of memory usage using Greenfoot. There are an average of 35 actors on the screen at a time. I used Greenfoot.setSpeed and set it to 37. However, it runs at more like it is at 20. Is there some way I can make the frame rate go up? When the file size was smaller it worked fine. Now sometimes it also complains about Java Heap Size overflow error. Is there a way to increase Heap size?
davmac davmac

2011/6/1

#
Are you calling setImage() in your code? Do you pass a filename argument or do you cache the image?
RockSmash RockSmash

2011/6/1

#
Yes, I use setImage(). I have a lot of animations in my game. Every frame, setImage() is called for multiple actors. I did not have problems having 15 or so actors animate before the file size got so large. Now that the file size is large, I can have just 8 or 9 animated actors and still have serious slowdowns. I use setImage(foldername + filename) to animate things. The folder is a smaller folder in the images folder. What is cache-ing an image? What is passing a file argument?
davmac davmac

2011/6/1

#
What is passing a file argument?
Passing a filename argument is what you are doing now. When you call the setImage() method you are giving it an argument which is a filename. If you do this, the file must be loaded from disk and the image must be de-compressed each time.
What is cache-ing an image?
In your class do:
1
private static final GreenfootImage image1 = new GreenfootImage("image1.png");
And then you can use:
1
setImage(image1);
... so instead of using a filename argument, you use an image argument. This avoids loading and decompressing the file every time you call setImage().
RockSmash RockSmash

2011/6/2

#
Oh... I see now. That helps. Thank you so much. You guys do a great job.
akilino akilino

2014/5/3

#
davmac wrote...
What is passing a file argument?
Passing a filename argument is what you are doing now. When you call the setImage() method you are giving it an argument which is a filename. If you do this, the file must be loaded from disk and the image must be de-compressed each time.
What is cache-ing an image?
In your class do:
1
private static final GreenfootImage image1 = new GreenfootImage("image1.png");
And then you can use:
1
setImage(image1);
... so instead of using a filename argument, you use an image argument. This avoids loading and decompressing the file every time you call setImage().
Sorry for coming to this topic, but same is happening to me. And...every time I add an image, I do addObject(). What I mean is that I created a class/subclass, everytime I wanted to add an Image. Is this bad?
You need to login to post a reply.