Impact

This forum is read only and just serves as an archive. If you have any questions, please post them on github.com/phoboslab/impact

8 years ago by Arturo

Hi!

I have a problem with impact that I wasnt aware of.
On my game, I dont use tiles, I use full images instead. I pretend that they are tiles, and I use them on WM, by dividing the big image in exact big squares (480px, 800px.... etc). Like this, I can keep working with WM and see the results of the image (to place object, etc).

I know WM is for tiles, but is similar concept I guess... and also is less complicate (my character is always centered, so I dont have to calculate the position of the images all the time, if I do it with WM)

Anyway... each image, is around 1.5MB, 700KB (1 png and the other is jpg).
With this method I found two problems....

1- I cant put more than 3 layers like this, if the layer are really big... the browser slow down suddenly so much... this is not a big problem, I just stick to the 2-3 layers with this image method.

2- And this is a big problem... after playing from start to the middle... after 10 levels... impact doesnt load the images anymore, but doesnt give any errors either. Load the player, and entities, and is playable, but not the images. sometimes load 1 layer or 2... but not the full layers of the game. Sometimes load some part of the layer...
I thought this is something realed to the memory of the game, that is full cos the images are too big, so I should be refreshing the images everytime I call a new level, but this doesnt seems to work....

I saw this post:

ImpactJS memory management

But I coundnt make it work (the game keep asking me for the images that I remove with ig.Image.cache = {};

Any clue where I should keep trying?
Thanks!

8 years ago by Joncom

Just out of curiosity, how much memory is the tab using around the time problems begin? How much memory does your computer have?

8 years ago by Arturo

Hi Joncom.

I cant really say how much is using, because if for a home-console, which has 1GB of memory.

I kind of sort the problem, but I'm not sure if is the right solution.
What I do know, when I call the first level, I call a function (free_memory) where I remove all big images from Image.cache, except for the current level.

From there, everytime that I call a new level, I add a variable (which I will never use) with new ig.Image() and the next level images. This make include in Image.cache, the new level big images.
Then, once is loaded, I call again this free_memory, to remove the level before images.

With this, I have no problem at all. It takes longer to load the levels, but not that much really. I'm not sure if this is the best solution, but is the only one that works so far.
Page 1 of 1
« first « previous next › last »