Animations cause game lag when scene is loading

Discussion in 'Technical Discussion' started by Christoph, Nov 13, 2015.

  1. Christoph

    Christoph Miniboss Boxer

    Joined:
    Oct 4, 2015
    Messages:
    2,807
    Likes Received:
    2,309
    What would be the solution?

    I am trying to delete some animations, but it seems with even just one animation used of 28 images (the coin) the scene lags sometimes. If I put all animated elements in the first scene of each level will it be pre-loaded so to say?
     
  2. Christoph

    Christoph Miniboss Boxer

    Joined:
    Oct 4, 2015
    Messages:
    2,807
    Likes Received:
    2,309
    I keep trying to limit the animations. I have several coins which all release different animations when picked up by the user. Others have different Appearance Chances but release the same animation. The appearing of the coins all are the same. I tried now to import the default coin animation as an object and place it in the Default Animation of each coin. This means I only have 1 coin animation in the entire game instead of 8 which all hypothetically could appear in one scene and slow down the loading. The problem? Even if the user picks up the coin, the animation just keeps going. Is there a way to make it stop?
    My settings are:
    Action Type: Coin
    Animation Placement: Powerup
    Animation Behaviour: Replace
    Animation Repeat: Single Play

    As said, this works great when the Default Animation is imported individually and directly into the Default Animation field but not with an object.
     
  3. Andy

    Andy Miniboss Boxer

    Joined:
    Sep 24, 2015
    Messages:
    2,152
    Likes Received:
    1,546
    Best to send email to support. If you have already let me know the ticket number.
     
    Christoph likes this.
  4. Christoph

    Christoph Miniboss Boxer

    Joined:
    Oct 4, 2015
    Messages:
    2,807
    Likes Received:
    2,309
    No, I have not. What is the support email? And what should I say or ask for?

    Update:
    The pre-load of animations seems not to work either. :( I attached all animations I have to the first scene of the level and there is no lag when loading. But the animations get loaded a second time when the large scene is loaded and the lag is there again.
     
  5. Andy

    Andy Miniboss Boxer

    Joined:
    Sep 24, 2015
    Messages:
    2,152
    Likes Received:
    1,546
    support@buildbox.com

    Send complete details on the issue and include the files and steps to reproduce the issues. Usually it is best to send 1 email per issue otherwise it can become a bit confusing.
     
    Christoph likes this.
  6. Christoph

    Christoph Miniboss Boxer

    Joined:
    Oct 4, 2015
    Messages:
    2,807
    Likes Received:
    2,309
    I just realized that my trial is due today or tomorrow. Instead of designing my last levels I was debugging my game. :( I will have no time to create a file reproducing the issues and I also don't want to send my entire game. Will use the last hours to see if I can find some alternative ways to make it half work.

    But basically it's all about the animations. If I take them away no lag. If I leave them, even just 1, there is lag when changing the scene on a iPhone 4s. I suppose it can be reproduced with any kind of animations, since my game only has fade in and out animations of platforms and other elements that are very small in size and resolution.

    Unfortunately, I will have to do some design changes, because I don't think this is something that will be corrected in BB 1 since the final version is about to be released. The animations looked great and gave life to the game. So I'm not sure what to do right now. Still, when I have the final design, I will purchase the monthly subscription which I hope is still this year and finish the game.

    There are a whole lot of problems with the Default Animations of Objects and Actions. For example, a lightbulb. If I isolate the animation of the bulb and import it directly to the Default Animation everything works great. But when I then add the stick that holds the bulb as an object everything gets messed up. When I put the entire lightbulb with stick now to my game and rotate it, the bulb gets rotated, but not the stick. Also, if I move it vertically or horizontally with another platform the bulb moves, but the stick not. Very weird.

    Another problem I found is when I start to rotate a coin for example with a helper element that is transparent, then the coin rotates, but the release animation is not showing anymore. Or if the coin is an object and not imported directly to the Default Animation then it never gets picked up. Not sure if this is a glitch or a feature.
     
  7. darren

    darren Avid Boxer

    Joined:
    Sep 25, 2015
    Messages:
    134
    Likes Received:
    58
    it's all a learning process, and just a heads up, anything between 0 and 100% opaque requires lots of CPU

    BB is very open in how you can use it (doesn't limit or warn against certain usage) and sometimes things don't function like you would hope.
     
    Christoph likes this.
  8. Christoph

    Christoph Miniboss Boxer

    Joined:
    Oct 4, 2015
    Messages:
    2,807
    Likes Received:
    2,309
    Do you mean a png with transparency or the transparency set in Buildbox?

    My animations have transparency but within the png. But if this is true, it could be a possible cause of the lag. If you can confirm I will try without the transparency then.
     
    Jamie likes this.
  9. darren

    darren Avid Boxer

    Joined:
    Sep 25, 2015
    Messages:
    134
    Likes Received:
    58
    see the good below...you can use the bad but it uses more CPU
    [​IMG]
     
    Christoph likes this.
  10. Christoph

    Christoph Miniboss Boxer

    Joined:
    Oct 4, 2015
    Messages:
    2,807
    Likes Received:
    2,309
    haha. Yes, I understand what transparency means. But does it apply also to pngs? Because my game has transparency all over the place but they are already included in the png.
     
    Jamie likes this.
  11. darren

    darren Avid Boxer

    Joined:
    Sep 25, 2015
    Messages:
    134
    Likes Received:
    58
    my point is, your game will require many more calculations at runtime to process any pixel that is between 0 and 100 opacity. if it's 0 that is easy to calculate...if it's 100percent, that is easy too... if it's 99percent, well now you have to calculate what is underneath to render what it should look like blended with what ever is underneath.
     
    Jamie and Christoph like this.
  12. Christoph

    Christoph Miniboss Boxer

    Joined:
    Oct 4, 2015
    Messages:
    2,807
    Likes Received:
    2,309
    This makes a lot of sense. Thanks for the explanation. I will try to delete most of the transparencies I have. Very exited because I think this could make a real change to the poor performance I experience on older devices. Fingers crossed.
     
  13. Florian Porkert

    Florian Porkert Boxer

    Joined:
    Sep 25, 2015
    Messages:
    22
    Likes Received:
    45
    I think that I found the problem. The images of an animation must all be stored in the SAME atlas. Even if e.g. just 1 image is stored in atlas #1 and all other images of the animation are stored in atlas #2, the game slows down when adding a scene with this animated object. You can try to reproduce it easily: Add a scene with 100 animated coins and you will see it. Then change the atlas size to e.g. 4096x4096 pixels so that all images of the animation are in the same atlas. The game won't lag anymore. But be careful. This is not a general solution. Some older devices do not support images of that big size. BTW - It does not lag in the Buildbox simulator. Only on all kind of devices.
     
    Christoph likes this.
  14. Christoph

    Christoph Miniboss Boxer

    Joined:
    Oct 4, 2015
    Messages:
    2,807
    Likes Received:
    2,309
    Yes, it only happens on device. And as I posted earlier, the atlas division was one of my first thoughts. Do you have an example project you could send to support? I do not have access to the software right now to do it on my own. And unfortunately, there is no way to manually move the images within the atlasses. What is the max. resolution of an atlas to support all devices including older ones?
     
  15. Florian Porkert

    Florian Porkert Boxer

    Joined:
    Sep 25, 2015
    Messages:
    22
    Likes Received:
    45
    For iOS you can use 4096x4096 pixels. All devices that support at least iOS 6 can handle this size. Even the iPad 2 and iPhone 4S support it. For Android you should use a max texture size of 2048x2048 pixels. Even though Corona automatically downscales images if they are too large for a device, the images will look unsharp. And with some Android devices you will still have problems with larger image sizes.
     
  16. darren

    darren Avid Boxer

    Joined:
    Sep 25, 2015
    Messages:
    134
    Likes Received:
    58
    Wow this is interesting! I didn't know that. By the way, 4096x4096 is similar to 4 sprite sheets in memory that are 2048x2048 so if you don't need the entire amount, you should also be able to use 4096x2048

    Edit: just check my 2 (2048x2048) atlases in MICROGEE and all my animations are on the corresponding sprite sheets. I have no significant lag in my game :) ... perhaps the layout of the sprites is due to my not deleting stuff very often as I test stuff in dummy files before committing the design. Or it could be the "Optimize / rebuild Atlas"
     
    Last edited: Nov 26, 2015
    Christoph likes this.
  17. darren

    darren Avid Boxer

    Joined:
    Sep 25, 2015
    Messages:
    134
    Likes Received:
    58
    Trying Android now…in my case, this didn’t help me. Glad it worked for you though. My game plays very nice on newer devices but stutters every 1 to 3 seconds for a very quick 1/10 of a second.

    Late 2012 Android 7inch tablet
    ARM Cortex-A9
    dual-core 4470 @ 1.3 GHz
    1 GB RAM memory
    1440×900 pixels @ 243 PPI
    Imagination Technologies PowerVR SGX544

    Perhaps my game is just too demanding…I’ve tried just one atlas 4096 x 2048, making all animations an even number to avoid possible odd numbered frame drop (.2 fps, .4 fps ect) and making my three backgrounds speed 1 or zero and then deleting the background pngs. nothing helped.

    Has anyone had lag or stutter and then improved it?
     
  18. Minhaus

    Minhaus Boxer

    Joined:
    Jul 10, 2017
    Messages:
    6
    Likes Received:
    0
    My game is stop 0.5 second when change the scenes. Anyone can help. All my images are small 1024x1024.
    Anyone can help please.
     
  19. Christoph

    Christoph Miniboss Boxer

    Joined:
    Oct 4, 2015
    Messages:
    2,807
    Likes Received:
    2,309
    1024x1024 is not small but huge! Try to make them 56x56 or so. Never scale down in Buildbox.
     
    Kevin W likes this.

Share This Page