Card game optimization and many animation frames in the sprite

Not favoritedFavorited Favorited 0 favourites
  • 10 posts
From the Asset Store
Create your own trading card game with this Fantasy TCG Card Template
  • Hello everyone. I have a card game in which I store a Cards object containing various images. I've reduced these images to a minimum of 105x131. But there's a problem. My Cards object has 20 types, specifically 20 animations. Each animation contains 100-200 frames, and these are the same 105x131 images. I'm afraid that if I store around 1000-2000 objects in a single sprite, even at this size, my game for low-end mobile devices won't even run them. Besides the cards, there are also various other UI objects that are larger. I don't know what to do or if there's a convenient way to store all of this. Perhaps you can help? I don't know, maybe I should split these animations into different sprites, then there would be 100 objects per sprite, but I already wrote the code with one sprite, not with different ones. I'll have to redo everything. Please recommend a solution for optimization.

  • I'll add to the post: 105x131 is the minimum size I can make. Although I need to use 140×174.

  • Each animation contains 100-200 frames, and these are the same 105x131 images.

    Just to clarify - the size is the same, but the images are different in each animation, right?

    A quick test shows that 1000 frames with that resolution use about 80-85 MB in memory. So your game should probably run fine, even on mobile. But I would try to reduce the number of frames in animations, 200 frames feels like a lot.

  • > Each animation contains 100-200 frames, and these are the same 105x131 images.

    Just to clarify - the size is the same, but the images are different in each animation, right?

    A quick test shows that 1000 frames with that resolution use about 80-85 MB in memory. So your game should probably run fine, even on mobile. But I would try to reduce the number of frames in animations, 200 frames feels like a lot.

    Yes, the size is the same everywhere, but the images are different. These images are different cards. I can't reduce them because my game is quite content-rich. And I give them complete freedom. The maximum I can do is cut down and use 170-180 animation images instead of 200. But don't forget about updates. Since the entire game is based on my cards, they're a core element in the game, and I plan to expand them.

    I specifically bought a test phone and am using my old one. My game runs on an Oppo A3, which uses about 100 MB of memory, and lags a bit, but overall works. And on a Meizu Pro 7, I get artifacts and a white screen with a sad smiley face in the upper left—basically, it crashes. Basically, 100 MB is already pretty critical. Although my card images alone weigh 80, not counting the UI and other objects.

    Maybe there's another solution? I tried asking the neural network, and they told me to split all the animations into separate sprites. But that doesn't change the essence of the problem if all these sprites are on the screen. It's the same thing.

  • Do you see that images only use 100 MB in the debugger? That's very modest memory usage, it should not crash a phone with 4GB of RAM. The issue must be with something else. Try collecting LogCat logs.

    If you need all cards (20 animations with 180 frames each) to be available on the same layout, then you’re right: splitting them into separate sprites won’t help.

    The only real option (if the art style allows it) is to break each card into smaller pieces — for example, a shared border/background sprite used by all cards, plus a smaller unique image for each card.

  • Do you see that images only use 100 MB in the debugger? That's very modest memory usage, it should not crash a phone with 4GB of RAM. The issue must be with something else. Try collecting LogCat logs.

    Yes, in the construct debugger

    I found an old screenshot with a video recording where the game, while idle and without any additional actions, simply crashed after a while. It's a different project, but it has the same memory consumption of around 100 MB.

    Yes, for me, that's a critical figure right now. Still, are there any recommendations other than improving the content in my game?

  • If you see memory usage increasing over time while the game is idle - it's a memory leak.

    But 100 MB for images should not crash a phone. I’ve made many mobile games in the past that used 300–500 MB for images, back when most budget phones only had 1–2 GB of RAM, and they ran just fine.

    Collect the LogCat log of the crash, you should be able to see what caused it.

  • I'd definitely recommend separate Sprite objects rather than one Sprite object with tons of content on it. See memory usage - Construct's memory management either entirely loads all a Sprite object's animations, or unloads them all; if you have everything in one Sprite, it will either have everything loaded or nothing, but if you have everything in multiple Sprite objects, you can have just some of those loaded.

    You can then add all those Sprite objects to a Family so you don't have to repeat events. You should be able to use 'Replace object' on your existing events with a Family so you don't even have to re-do the events.

    And on a Meizu Pro 7, I get artifacts and a white screen with a sad smiley face in the upper left—basically, it crashes.

    These are characteristics of graphics driver bugs. So it might be crashing due to a buggy GPU driver rather than running out of memory.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Construct's memory management either entirely loads all a Sprite object's animations, or unloads them all; if you have everything in one Sprite, it will either have everything loaded or nothing, but if you have everything in multiple Sprite objects, you can have just some of those loaded.

    I'm also making a card-type game and I was looking for this information, it might be helpful to add this to the sprite page in the manual

  • I recommend keeping the cards images on the files folder and load them dinamically

    Ashley approach could work but is a little annoying to deal with +100 objects

    You can look the implementation here

    dropbox.com/scl/fi/necc6b10p02m6v85ukd1t/force-of-will-automatic.c3p

    Go to Event Automatic > event 953 > setFrame

Jump to:
Active Users
There are 0 visitors browsing this topic (0 users and 0 guests)