-
Notifications
You must be signed in to change notification settings - Fork 450
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pass FlxG.elapsed through update methods #1188
Comments
It doesn't matter if it's optional or not; when overriding functions signatures must match. And considering This would be a May be worth noting: Flambe has this already, HaxePunk does not. |
The slowing/speeding effect pretty fundamental capability when it comes to polish, and certain game mechanics aren't really possible without it. You'd be hard pushed to find a AAA game that doesn't use it somewhere, even if there's not really any gameplay effect. Other libs that do this (with render too in some cases) include LWJGL, Slick, LibGDX, and XNA/Monogame. Unity, on the other hand, does not as far as I can tell. I'm also trying to think of other ways of implementing the effect. One way might be to give FlxObject or FlxBasic their own timescale property, and replace their uses of FlxG.elapsed with a local property Another option, but this one rather hacky and could potentially break in some circumstances, would require FlxG.elapsed to be writeable (whereas at the moment it is read-only). Then this would be possible:
|
I've done that hack before, it's pretty nasty, but it works. I don't think it's worth making this change, it would be a huge headache for all existing users. |
@gamedevsam That hack isn't even possible right now. FlxG.elapsed cannot be written to. |
Maybe it should be then.... |
Not sure we should encourage that kind of hack... there might be better solutions. |
The only other possible solution I see atm is what @JoeCreates mentioned, adding a timeScale property to FlxSprites and FlxGroups to apply selective slow-mo or speedup. |
How would this work for FlxGroups? Children's timeScale gets multiplied/divided by the Group's when added/removed? Does that mean that values of 0 shouldn't be allowed to avoid a divide-by-zero? How would the new timeScale affect FlxAnimation (maybe others), since that uses FlxG.timeScale directly? |
Most game engines tend to pass a time delta down through update() methods, whereas HaxeFlixel uses a single static variable
FlxG.elapsed
. The problem with this is that it gives no control to updating classes over how quickly they should update.HaxeFlixel has
FlxG.timeScale
for if you wish to slow down or speed up the game, but when is it ever useful to slow down or speed up everything? Generally if you want to have such an effect, you'll have a HUD updating at a constant rate while the world updates at a different speed.For this reason, I would suggest
update()
methods are replaced withupdate(elapsed:Int)
. It would this be trivial for any updating object to have it's own elapsed coefficient for changing the speed at which its members update.It might be possible to stop this change from being a breaking change by making
elapsed
optional?The text was updated successfully, but these errors were encountered: