flixel icon indicating copy to clipboard operation
flixel copied to clipboard

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

Open Rudyrue opened this issue 1 year ago • 18 comments

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 avatar Feb 29 '24 22:02 Rudyrue

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

Rudyrue avatar Feb 29 '24 22:02 Rudyrue

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?

Geokureli avatar Feb 29 '24 22:02 Geokureli

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 avatar Feb 29 '24 22:02 Rudyrue

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

Rudyrue avatar Feb 29 '24 22:02 Rudyrue

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"?

Geokureli avatar Feb 29 '24 22:02 Geokureli

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 avatar Feb 29 '24 22:02 Rudyrue

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

Rudyrue avatar Feb 29 '24 22:02 Rudyrue

maybe cameras too

Rudyrue avatar Feb 29 '24 22:02 Rudyrue

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

Geokureli avatar Feb 29 '24 22:02 Geokureli

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

Rudyrue avatar Feb 29 '24 22:02 Rudyrue

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

Geokureli avatar Feb 29 '24 22:02 Geokureli

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

Rudyrue avatar Feb 29 '24 22:02 Rudyrue

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

Geokureli avatar Feb 29 '24 22:02 Geokureli

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

crowplexus avatar Feb 29 '24 22:02 crowplexus

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 avatar Feb 29 '24 22:02 Rudyrue

fuck wrong comment 😭

Rudyrue avatar Feb 29 '24 22:02 Rudyrue

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 avatar Feb 29 '24 23:02 Geokureli

accidentally closed this, reopening

Geokureli avatar Mar 01 '24 13:03 Geokureli