GMS 2 How do I pause a tileset's animation?

Discussion in 'Programming' started by Peej4321, Aug 30, 2019.

Tags:
  1. Peej4321

    Peej4321 Member

    Joined:
    Nov 9, 2018
    Posts:
    14
    I can't believe there isn't just a way of doing this. I mean, what is everybody else doing when they reach this problem? How many games are there that have been made in GMS2 where there are animated tilesets and the game can be paused and still show the game frozen in the background? How are people doing this? The only other evidence I can find anywhere of other people trying to find a solution to this is this one old thread (https://forum.yoyogames.com/index.php?threads/pausing-animated-tiles.26340/) but they basically say you can't do it. Someone mentions getting the frame index of a tileset every frame and then setting it to the one it's already on every frame that it's paused, but there is no way of setting the frame index of a tileset. They also mention the possibility of making the language defined functions tilemap_pause() and tilemap_unpause() one day, which would be a Godsend at this point, but how would I even find out how close those are to completion?
     
  2. Posh Indie

    Posh Indie Member

    Joined:
    Dec 5, 2016
    Posts:
    200
    You could always create a surface with the current contents of the screen, then draw that on top of the game itself, but under the pause menu. Only release the surface once the game is unpaused.

    There are numerous ways to speed this up, as well, and to get more desirable results with what you are specifically trying to achieve. Get this working before moving on to optimizations, though, haha.
     
    Last edited: Aug 30, 2019
  3. Peej4321

    Peej4321 Member

    Joined:
    Nov 9, 2018
    Posts:
    14
    Okay, thanks, that's a pretty good solution. But when you "resume" the tileset will be on a completely different frame of animation to the one it was paused on. Also I have a feature in my game where you can move the camera around while the game is paused, so it wouldn't work anyway.
     
  4. Posh Indie

    Posh Indie Member

    Joined:
    Dec 5, 2016
    Posts:
    200
    As for the frame issue, you could alway keep track of the timing, yourself, and "actually" unpause when it makes sense (wouldn't be long enough to be a huge deal).

    The camera moving would be an issue in this case, though. I mean... there are still options, but it is hard to give you a solution without all the details.

    You could always make a surface that is sufficiently larger than the camera in use, and recreate the contents of the surface based on the new location every X amount of frames while moving, where X corresponds to a valid time where the animated tiles would be at the same frame of animation as when you first paused.

    Couple that with the slightly delayed "unpause" based on the timing of the tile animations to ensure it resumes at a time where the frame would be the same as that of when it was paused.

    I honestly have not had a need to flat out pause anything I have worked on in GMS2 (Let alone the animated tile system), so this is all off the top of my head. For all I know there could be an easier way, haha. I just figured I would toss some ideas out there.
     
  5. Peej4321

    Peej4321 Member

    Joined:
    Nov 9, 2018
    Posts:
    14
    Okay, thanks. I think I might as well just completely handle the tile animation manually, because that would probably be easier than working with surfaces all while there are layers of paralax backgrounds in play too. I'll have to make individual tilesets to change between manually, and then I can actually pause them. It's just disappointing that there's no way of doing it within the actaul system that the engine provides.
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice