User Tag List

Page 1 of 2 1 2 LastLast
Results 1 to 10 of 12

Thread: Saving states when switching between frames

  1. #1
    No Products Registered

    Join Date
    Jul 2006
    Posts
    111
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Saving states when switching between frames

    I've been trying to do something very, very simple for...*checks watch* five straight months now.

    All I'm trying to do is switch from frame 1 to frame 2 and back, while keeping frame 1 the way it was before. That's it. Nothing more complicated than that.

    Yet MMF has fought me to the bloody bitter end about it.

    The simple solution seemed to be to use the save and load frame actions. After a few days of utterly wasted work followed by a trip to the forums to find out that the frame doesn't save until the end of the event loop but frame transitions are instant, I finally got it to save correctly. However, loading it again has proven to be nothing short of demonic for what appear to be the stupidest of reasons.

    Now that I've managed to fix the crashes, the problem is that frame 1 will instantly jump back to frame 2 every single time you try to return. I'm assuming this is because MMF is forcing me to set a variable that tells it when to switch to frame 2, since the frame switch event has to actually be placed before the saving event and run on the next loop (since it doesn't save until the end of the loop, meaning if I just try to save > switch nothing will get saved). I can only assume that that variable is being loaded when the rest of the frame is being loaded, meaning it's current value gets overwritten to what it was just before it jumped and it thinks it's supposed to jump to frame 2 again. All attempts to manually overwrite it after the loading event itself have no effect.

    At least, this is what happens when I try using a global variable to control the frame jumps. I have also tried using an ini file; if this is the case, the game simply won't load the frame data at all (though I have verified that all of the ini data is there and correct). I tried using the named variable object to store the variable in the hopes that the save frame action wouldn't include it. This was actually the first way I tried it, and while it worked, it also left MMF in a highly unstable state where there were massive graphical glitches and objects blinking in and out of existance. I can only assume this was specifically to spite me.

    The basic event sequence is exceedingly simple:

    *** Frame 1

    + Variable "Load Frame Data" = 1
    - Jump to Frame 2

    + Start Of Frame
    + "Load Frame Data" = 2
    - Load Frame Position
    - "Load Frame Data" = 0

    + Upon Pressing "`"
    + "Load Frame Data" = 0
    - "Load Frame Data" = 1
    - Save Frame Position

    *** Frame 2

    + Upon Pressing "`"
    - Jump to Frame 1

    + End of Frame
    - "Load Frame Data" = 2

    ...Yet it manages to fail in the most spectacular ways, depending on how I tweak it. I've even crashed MMF several times. Most of the time, though, it just persistantly ignores me by either clinging with desperate tenacity to frame 2 or plodding ignorantly along using every ounce of digital willpower it has to ignore the "load frame position" command's existance.

    That is the version that uses the global variable ("Load Frame Data"). It results in being trapped in frame 2; each time you try to go back to frame 1, it goes back for a split second and then returns to frame 2. I have checked for other events that might be affecting it and there are none, and everything I do has the same result: Either it won't load or it forces frame 1 to jump back to frame 2 again the second it loads.

    Surely I'm not the first user who has ever wanted to have an inventory screen or somesuch? I'm going to need several such subscreens. I could do without some of them by making workarounds or integrating them into the main screen, but there are some that just can't be fudged and the game won't function without them. I can't afford to keep putting so much development time into projects only to have stupid random things like this constantly murder them. If anybody knows what's wrong or knows of a better way, please let me know.


  2. #2
    Clicker Multimedia Fusion 2

    Join Date
    Jun 2007
    Location
    Suffolk, UK
    Posts
    435
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Saving states when switching between frames

    This is just a random guess and since you've been working on this for so long you may have already thought of it but I'll mention it just in case:
    You said that when you go from 2 back to 1 it instantly goes back to 2 again. There's a chance that this may be because it's still recognising the button press since MMF will probably run through numerous loops before you can get off the button. If you follow the track of your conditions, if it's still recognising that the button is pressed you would end up back at frame 2 again.
    Try adding a variable which will record when the button has and hasn't been pressed and factor that into your two button presses on the frames. So when the button gets pressed set it to 1 or if using strings, to true. Then have a condition somewhere which resets that variable to 0 when the button isn't pressed. Then for the conditions that use that button add a condition for that variable being 0 (or false).
    I had to do this before in a small project where the same button was used to call a sub-app and the same button was used within the sub app to remove it.
    If you've already tried that, I'm out of ideas, sorry

  3. #3
    No Products Registered

    Join Date
    Jul 2006
    Posts
    111
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Saving states when switching between frames

    You said that when you go from 2 back to 1 it instantly goes back to 2 again. There's a chance that this may be because it's still recognising the button press since MMF will probably run through numerous loops before you can get off the button. If you follow the track of your conditions, if it's still recognising that the button is pressed you would end up back at frame 2 again.
    I did think of this and tried two different things to fix it. I tried changing which key frame 2 used (so it was different from frame 1) and I tried adding a time counter to the keypress event in frame 1 so that the frame had to have been running for a certain amount of time before it could switch. Neither worked.


  4. #4
    RayMarble
    Guest

    Re: Saving states when switching between frames

    Massive bump! So have you managed to find a solution to this in the end? I had a very similar situation and almost managed to solve it.

    In my case, I finally tamed the saving / loading frames but it turend out that under certain conditions objects with path movements make it crash so I wasn`t able to use what I learned in the end... hopefully it`ll be fixed in the next build.

    Meanwhile, you can upload a clean version of your file so maybe somebody can take a look I guess...

  5. #5
    RayMarble
    Guest

    Re: Saving states when switching between frames

    In fact, by looking at your code, I think it shouldn`t work... I`ll try to test it next week.

  6. #6
    No Products Registered

    Join Date
    Jul 2006
    Posts
    111
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Saving states when switching between frames

    At the time, no, I never got it to work. Whenever I finally did manage to get it to switch back and forth, it started crashing when attempting about 2/3rds of the switches. (At best I was able to get from frame 1 to frame 2 and back twice.) I had to abandon the project because of it.

    However, I've been tinkering with it for the last few days and I did finally get it to work. Apparently all of my stuff was right the first time in the basic sense, but MMF has several hotbuttons you need to intentionally step around. There are at least three glitches in frame loading; one's a bug, one is probably intentional (apparently it loads data at the end of a frame just like it saves it at the end of the frame...or something...such a pain) and one is kind of just a quirk that they may or may not already know about.

    First, keypresses are apparently inherited when you switch frames; if I use the same key to switch from both frames it will stop me from switching (the key I press to switch to frame 2 will immediately trigger the same "key is pressed" event in frame 2, meaning it will instantly bounce me back to frame 1). I had to change it so the two frames use different keys.

    Second, there's a timing problem with using values to control loading, but thanks to MMF not saving until the frame is over, you have to do that. If I save and try to switch on the next frame, I'll get stuck on frame 2 (the value that I am using to control the frame switches can be changed on the frame that I load it, but that change will be ignored. Thus, it will use the value it had when it saved, which--since I can't save and switch frames during the same frame either--has the value set to switch the frame). To get around this I added a timer to the frame change event so it resets the value that controls the switch at a certain time and won't perform switches until after this time has passed. (Instead of being "Load Frame Data = 1" it is "Timer is greater than 0.20 and Load Frame Data = 1" with a "Timer is greater than 0.10: Set Load Frame Data to 0" in between). Thus, the value will still be wrong when the frame loads no matter what you do, but it won't matter in practice.

    Lastly, there is a crash bug that has something to do with the timing of a frame switch. Having two switches in rapid succession seems to cause a crash. Luckily, I had already determined that the graphics freakout was being caused by something else (the string object's stupid "display as background" setting was somehow causing it) because otherwise I'd still think it didn't work.

    Now I've got it *mostly* working. It is still loading the speed of the objects incorrectly, and may be loading other things wrong too (I haven't checked very thoroughly yet). I have confirmed that the speed problem isn't my code; MMF is setting the default and max speed of the active objects to their default values rather than the values they had when the frame was saved.

    But anyway, the formula that works seems to be this:

    *** Frame 1:

    (The events must be in this order)

    + Timer is greater than 00".20
    + Load Frame Data (which is a global value) = 1
    - Jump to Frame #2

    + Start of Frame
    + Load Frame Data = 2
    - Load Frame Position (filename)

    + Timer is greater than 00".10
    + Only one action when event loops (this isn't strictly necessary, but I figure it's probably a good idea)
    - Set Load Frame Data to 0

    + Timer is greater than 00".20
    + Load Frame Data (which is a global value) = 0
    + Upon pressing the (whatever) key (or whatever other event triggers the switch)
    - Save Frame Position to (filename)
    - Set Load Frame Data to 1

    *** Frame #2

    + Timer is greater than 00".20
    + Upon pressing (key that must be different from the key in frame 1, if you happen to be using a keypress like I am)
    - Set Load Frame Data to 2 (this can alternately be put in an "End of Frame" event)
    - Jump to Frame #1

    Leaving out the timer events causes crashes when I switch frames and setting the Load Frame Data value to 0 fails if I try to use the "Frame Loaded" event or if I try to do it in the same loop as the frame loads (leading to getting stuck in frame 2). In fact, everything failed except the timer-based solution.

    So that's where it's at right now. I'll have to find a workaround for the speed bug and hopefully Clickteam will fix both it and the crash bug. (And the frackin' "display as background = I will humpz0r your display" bug...) I worry about the crash bug simply because it may involve something that's running in the background that might take longer under certain circumstances, meaning my arbitrary value of 00".20 won't always prevent crashes. It may also just be that it's getting stuck in a loop when trying to load itself (if it's overwriting the values from a frame at the end of the loop with loaded values or something) in which case my solution would work forever. But that's the kind of thing that's nice to know before you dump even more time into a project that was already brought to a screeching halt twice...

  7. #7
    RayMarble
    Guest

    Re: Saving states when switching between frames

    First, keypresses are apparently inherited when you switch frames; if I use the same key to switch from both frames it will stop me from switching (the key I press to switch to frame 2 will immediately trigger the same "key is pressed" event in frame 2, meaning it will instantly bounce me back to frame 1). I had to change it so the two frames use different keys.
    Not sure we think about the same thing but I made a quick test and this isn`t the case? Grab the file here.

    On a related note, why can`t we attach files here, this is so awkward >_< two forums: I have to make the post there, paste the link here, go back and edit that post to link to the source thread here .. where was I?

    Edit: it`s also possible the crashes are related to something else. In my case, once it was because an array didn`t have "create before frame fade-in" when a frame I used had a fade-in transition (??? don`t ask...) and on the other occasion some actives had a path movement (took me more than a week to figure this out).

  8. #8
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleiOS Export ModuleSWF Export ModuleXNA Export Module

    Join Date
    Jun 2006
    Location
    UK
    Posts
    519
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Saving states when switching between frames

    You know if it's an inventory screen you wanted, why not just of used a sub-application? Would of saved you a lot of effort.

    Besides it's not that difficult to save and load values within MMF. Not as you make it sound anyway. You seem to blame MMF for mistakes you make, if it isn't you mistake, it's a bug within MMF and should be reported as such .

  9. #9
    Clicker Multimedia Fusion 2 Developer

    Join Date
    Jul 2006
    Location
    Denmark
    Posts
    1,812
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Saving states when switching between frames

    I doubt you've attempted to do this for 5 months, or else you would've figured out global values by now.

    yes it was too long to read but I assume the best way would be global values, or some kind of array.
    Or, listing all the values needed as parameters in a single global string.

  10. #10
    RayMarble
    Guest

    Re: Saving states when switching between frames

    I don`t know whether the OP wanted to make an inventory (the example I used was just ripped out of some stuff I was working on) but regardless, there are some serious advantages of why somebody would want to make an inventory with saving / loading instead of with a subapp - it`s just so much more practical and elegant.

    For example, suppose you want to have part of your inventory semi-transparent - with a subapp, you would have (or "would of", eh?) to save a screenshot of your frame, put up your subapp that has an active picture in the far back layer; load the screenshot into the active pic; do the stuff you want to do in the subapp/inventory; take care that all the stuff gets actually transferred to the main app (for example global arrays aren`t automatically updated under certain circumstances so one has to do it manually); close the subapp. Is this elegant? And if we add to this manual saving of your game state via some arrays or other horrible ideas... Forget it.

    With a save / load frame, you could simply save the frame of your main app, jump to the frame with your inventory that has "keep display from previous" checked, do the stuff there and jump back.

    ...but in TGF the thing just crashes if you have actives with paths. Maybe this can be achieved with some transparency masks in MMF, I don`t know.

Page 1 of 2 1 2 LastLast

Similar Threads

  1. Few frames vs Multiple frames - game help needed
    By Marllux in forum Multimedia Fusion 2 - Technical Support
    Replies: 8
    Last Post: 4th September 2013, 05:13 PM
  2. Switching between frames movement bug
    By Top_of_the_Temple in forum Multimedia Fusion 2 - Technical Support
    Replies: 2
    Last Post: 30th August 2013, 06:18 AM
  3. Crash at exit/ switching frames
    By Kid_Roleplay in forum Multimedia Fusion 2 - Technical Support
    Replies: 6
    Last Post: 24th November 2010, 04:51 PM
  4. Why is it flashing when switching frames?
    By RayMarble in forum The Games Factory 2 - Technical Support
    Replies: 4
    Last Post: 10th March 2009, 11:31 PM
  5. question when switching frames
    By Jikito in forum Multimedia Fusion 2 - Technical Support
    Replies: 3
    Last Post: 30th November 2007, 06:58 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •