I'd post this as an article, but I think it's too poorly tested to be article material.
This is a simple way to create a slow motion effect. Just make a new global value, name it time and set it to 1. To make time faster, set the value higher than 1. To make time slower, set the value lower than 1. Do NOT use 0 to "freeze" time! (It might crash your game later, if you decide to divide by time.)
Now, in every event where you're moving something by an amount, just add "*time" to get "amount*time". (Parentheses may help.) For example (below), we have two moving platforms, normally moved using "set X to X+amount". To make them influenced by our time effect, we make that "set X to X+(amount*time)".
That's it!
Well, not entirely. If you look at the example (below), this isn't a perfect method. If you're moving by an odd amount, like 3, then you're going to have a platform that will move faster going to the left than the right when you slow time down (by setting it to 0.5 or something). This can probably be fixed, though.
Now, that's it. Though, you could always extend this concept further. You could make behaviours for different objects that apply the time effect to their own variable (set Alt Value A to Global Value A), and have them react to time dilation differently. You could have an enemy that is immune to the effects of time control, either by omitting the behaviour or omitting the 'amount*time' function from their movement events. You could have puzzles where traps are effectively oppositely by time, by using an 'amount/time' function; 0.5 would make it faster while 2.0 would make it slower. In fact, in the example (below), the moving platform on the right (purple) has this "negative" behaviour!
Awesomeness. I was thinking of applying such a thing to my game. But in it everything but the player is affected by time so you can have the cool castlevania type time stop effect
I'm tempted to say "Use the time scaling option in Construct"
Yeah, your idea should work, if I understand it right. Heck, it should be used for every game, slow motion or not, because the timers in games are out of sync with the frame rates, so it would get rid of quite a lot of bugs, especially in movement engines.
Disclaimer: Any sarcasm in my posts will not be mentioned as that would ruin the purpose. It is assumed that the reader is intelligent enough to tell the difference between what is sarcasm and what is not.
There is another way to do this (only with a custom engine though), but I have to wrok out how to explain it in my head though. It's only an "effect" though. It's not the "proper" way to do it.
Originally Posted by DudeHuge Wow cool beans!! Would this time effect only work in a completely custom engine?
If you're doing it in MMF2, it could only be made with a custom engine. Um, most things would be made in a custom engine. Nobody uses MMF2's built-in platform engine anymore
Disclaimer: Any sarcasm in my posts will not be mentioned as that would ruin the purpose. It is assumed that the reader is intelligent enough to tell the difference between what is sarcasm and what is not.
I believe ive developed a superior method in my custom engine, although i dont know if it'll work with people who code differently from me. This method is also PERFECT for people who have laggy games because they create too many objects on the screen too fast, and ill tell why later.
Basically you have 2 values. A frame timer, and the frame limiter. You use the Fastloop extension and always run a loop that adds 1 to the frame timer at all times, so that it matches the amount the FPS.
(In my app, there is an active object in the frame that stores these values, but it really doesnt matter.)
This value will count how many frames go by, and will continue to increase. The second value, (Frame Limiter) can be altered at anytime during the level. This value is to reset the frame timer once the number of counted frames meets/exceeds the Frame Limiter value.
1)Always = start loop(frametimer) for (60 loops) <--(or whatever the FPS is)
2)On loop (timerloop)= Add (loop step) to Alt value (Frame Timer)
3)When Alt Value (Frame Timer) is >= to Alt Value (Frame Limiter) = set Alt Value (Frame Limiter) to 0.
Now, in every frame where an object is being moved, or anything that has to do with time, put in the event (Frame Timer = 0). To freeze the animation of the character, put the event --Alt Value (Frame Timer) > 0 = Stop animation). Do the same to continue the animation once the timer is at zero again.
To create the Slow motion effect, simply increase the Frame Limiter by a number. it will stop the movement and animation of everything you told it too by however many frames you set the Frame Limiter to.
No crashing, no FPS screwups, and best of all, you can keep some things moving perfectly while others are in the slow motion state. You can even create more than one Frame Timer value, in order to slow some things down more/less than others, or to create a "superspeed" effect for the player.
The only drawbacks to this method are that it LITERATELY limits movement by however many frames you set the limiter to. Therefore, if an object is moving extremely fast and you slow it down, it will appear to be teleporting distances because everytime it moves, it will move the amount of pixels its supposed to. (in other words, no inbetween frames, unless you program it to move the inbetween pixels during its slow time.)
Also, for this same reason, objects that are slowed down too far may give the illusion of the FPS of your application running EXTREMELY slow, even though its running perfectly fine. If your character is slowed down and the camera is following him it will skip around while it follows them. (otherwise, if the only point of reference is slowed down, everything will look laggy lol.)
Theres a way around this, you just have to be smart.
------------------------------------------------------------
Im also sure some of you have met the problem with FPS rape when you create items too fast. This (most of the time) is because of the MMF Timer events. (every xx.xx secs, create X.) The MMF timer follows the clock of the computer, not the framerate of the application. Because of this, when you create objects that start to slow the framerate, the timer event that creates them continues to create them at regular intervals, which in essence is FASTER than it was before the application started to slow down, severly worstening the situation, creating objects faster than they destroy themselves.
By using a method similar to the one i explained above, even if you are severely slowing down your application, you will still be creating objects at the exact same intervals, since you are timing them by frames instead of seconds that dont follow the application, which will stop your application from eventually freezing itself up.
Only drawback to this is to completely replace the clock, you'll need to create your own timers by syncing up multiple counters/values to the framerate. However, the performance of your game will increase dramatically.
@Shab: I suppose there's no "proper" way to create bullet-time/slow-motion, as we need to manually change the speed of everything when we want to use it and have to individually manipulate everything rather than just tell the entire game; "Slow down a bit!"