HaxeFlixel / flixel

Free, cross-platform 2D game engine powered by Haxe and OpenFL
https://haxeflixel.com/
MIT License
1.97k stars 434 forks source link

Setting `active` to false on `FlxState`s completely softlocks the game #3056

Open Rudyrue opened 7 months ago

Rudyrue commented 7 months ago

was looking through how FlxGame updates the game and i realized that update() just blocks the function entirely if the state isn't active

this also blocks anything else from updating, like plugins or sounds or even the cameras

couldn't you just check if the state is active in FlxState's tryUpdate function? i feel like this was an oversight and it doesn't really make much sense to stop the entire game from updating as a whole because a state's active variable was set to false

Rudyrue commented 7 months ago

i also realized that this sorta applies to exists too you could just apply it to the tryUpdate call instead of affecting everything else

Geokureli commented 7 months ago

this IMO is expected behavior, setting any flixel things's active or exists to false prevents update calls to it, setting visible to false prevents draw() calls, why should this behave differently?

what else were you trying to do by setting it to false?

Rudyrue commented 7 months ago

setting any flixel things's active or exists to false prevents update calls to it

yes but this also prevents anything else that's unrelated to the state to not update, that's why i was confused on why it did that

what else were you trying to do by setting it to false?

trying to prevent the main game loop from updating at runtime with my own loop with openfl's Event.ENTER_FRAME i would probably have to use it anyways but it's still a bit weird that a state not updating prevents everything else that's not connected to the state to just not update

Rudyrue commented 7 months ago

i was going to make a pr for this but on second thought there might've been something that required that like state switching which i guess you could just make a variable for state switching but eh

Geokureli commented 7 months ago

trying to prevent the main game loop from updating at runtime with my own loop with openfl's Event.ENTER_FRAME i would probably have to use it anyways but it's still a bit weird that a state not updating prevents everything else that's not connected to the state to just not update

can you be specific about what things are "not connected to the state"?

Rudyrue commented 7 months ago

can you be specific about what things are "not connected to the state"?

plugins, sounds, cameras, elapsed, inputs etc they update seperately from the state's tryUpdate so im just wondering why the state not being active kills those

Rudyrue commented 7 months ago

i guess inputs make sense though cause you don't use inputs outside of states

Rudyrue commented 7 months ago

maybe cameras too

Geokureli commented 7 months ago

I feel like you're going a weird way about solving a problem, maybe take a step back and say what you're trying to do in the first place and why you (potentially) wanna reinvent the wheel here

Rudyrue commented 7 months ago

I feel like you're going a weird way about solving an problem, maybe take a step back and say what you're trying to do in the first place and why you (potentially) wanna reinvent the wheel here

im not trying to reinvent the wheel, i was wondering why flixel prevents other objects from updating if a state stops updating because flxgroups don't stop another flxgroup from updating if that one group isn't updating

Geokureli commented 7 months ago

right but if a flxgroup is a member of another flxgroup that has active = false, then its expected that both groups will not update, and the state is the top of the chain in flixel

Rudyrue commented 7 months ago

right but if a flxgroup is a member of another flxgroup that has active = false, then its expected that both groups will not update, and the state is the top of the chain in flixel

ohh ok that makes more sense

Geokureli commented 7 months ago

you could always just override your state's update func and not call super or something, but I really recommnd just saying what you're trying to do in the long run

crowplexus commented 7 months ago

if there's no state there's no reason to update other stuff separately

cameras don't update if the state isn't there because where will you use cameras? same for plugins, sounds, signals 100% of the time you are in a state so there's no real reason for stuff to update if the state isn't really there to begin with

Rudyrue commented 7 months ago

you could always just override your state's update func and not call super or something, but I really recommnd just saying what you're trying to do in the long run

yea that's why the exists check is there im talking abt the active check cuz a state can still exist but not be active

Rudyrue commented 7 months ago

fuck wrong comment 😭

Geokureli commented 7 months ago

you could always just override your state's update func and not call super or something, but I really recommnd just saying what you're trying to do in the long run

yea that's why the exists check is there im talking abt the active check cuz a state can still exist but not be active

I don't understand this comment

Geokureli commented 7 months ago

accidentally closed this, reopening