Is it possible to retrieve the number of frames in an application and place that number in a variable (or use it in a calculation)?
I have had a search around, but cannot find it.
Printable View
Is it possible to retrieve the number of frames in an application and place that number in a variable (or use it in a calculation)?
I have had a search around, but cannot find it.
Since you can't exactly add or remove frames at runtime, can't you just make a global values that you change to have the number of frames?
No need to be snooty. :whistle:
[size:8pt]-StephenL[/size]
Yes, I could, but it would be more convenient if the number of frames could be determined at runtime.Quote:
Originally Posted by LB
The reason it would be helpful is that my game has an intro screen and a game over screen, and all the other screens are 'levels'. Currently, I have a global variable in which I store the number of levels, so that Global events only occur within the game levels and the intro/game over levels. Every time I add level, I have to change the global variable. It's not a massive problem, but I don't know how many times I have added a level, tested the game, and then found that the new level doesn't work correctly because I have not changed the "Number of levels" global variable, so I have to go back and change the global variable.
I could also change my game over frame so that it is frame 2, then I could check for 'if frame number > 2', but that means a bit of recoding.
I can make the changes, but it would be easier for me if there was a way to access the number of frames, hence my question.
Do you know if there is such a facility?
Would it work if you just set the opening screen to jump to your say splash screen frame which you put as the last frame in your application and then there have something like
Start of frame:
Set variable to (number of current frame)
And then jump back to whatever frame your game / editor is. I guess you'll have to adjust the number to maybe (number of current frame)-1 or something depending on what you need.
Actually, that will do the trick so I won't have to manually change a global variable each time I add a level (which is the problem I am trying to overcome).Quote:
Originally Posted by RayMarble
If, at the start of the application, there is a jump to frame X (where X is the last frame) and in frame X I set a global variable to "current frame" as you have stated, then it will always be correct, even when new frames are inserted before the final frame, because MMF2 adjusts the "Jump to Frame" accordingly when new frames are added.
LB, unless I have misunderstood your message, I would have to manually enter the number of the last frame into a global variable every time I added a new frame, which is what I am trying to avoid.
I was bored so I made this example. Don't ask how it works!
http://clickteam.info/looki/Examples/FrameCount.mfa
Requires Overlay Redux and Memory object.
http://www.aquadasoft.com/Memory.zip
http://www.bumderland.com/objects/Overlay.exe
I really don't recommend you to use it. :)
But if you insist...
It was kind of you to do that, but all my MMF2 work gets exported to a SWF, and I don't think those extensions are available for the SWF exporter.Quote:
Originally Posted by Looki
Thanks anway.
I just made an example how to do it in Flash with Flash Haxx.
The solution is much cleaner. It will not work in MMF.
http://www.clickteam.com/epicenter/ubbthreads.php?ubb=showflat&Number=198611&#Post198 611
Is it really necessary to use two extensions or Flash Haxx to achieve something so simple >_>?
Is it really necessary to have an expression for something that doesn't change at runtime?
Seriously, people. Don't be lazy, just set that global value. Global values are unlimited so why worry?
You are being somewhat presumptuous to call me lazy, and cannot have read why I wanted to determine the value at runtime. To reiterate...Quote:
Originally Posted by LB
Using a global variable, when I add or remove levels to my game, I must change the global variable accordingly. I have already accepted that this is not a difficult task. However, when frequently changing the number of levels (which I have done whilst testing), I frequently forget to change the global variable which means that I frequently waste a small amount of time.
Agreed, it's not a big deal, but if I can avoid the problem with a one-off piece of code that is going to 'cost' me little in the way of time to implement, then that's what I will do. To me, that is not being lazy; it is a common-sense approach to avoid wasting time.
There is more than one "right" way to do things!
Using some sort of value that's programmatically determined is definitely the way to go whenever possible... that's what they're for!
I ended up in the same position (having to work with yet-to-be-decided number of levels etc) so I just tried to implement this myself... and realized a silly workaround that unfortunately has to be used with this method (of jumping to the last frame in order to count them) wasn't mentioned.Quote:
Originally Posted by Digitalic
In order to make MMF2 jump to whatever is the last frame you just have to enter a number higher than the number of frames you ever plan to have, and once there, proceed to grab the number of the current frame etc.
It's stupid but from everything I tried it seems there's absolutely no other way to do what we're after :(