You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hey! Thanks for creating Scale! It's been helpful on my first DR game.
One thing that didn't please me was how all the game Scenes had to live inside the same scope. I understand how handy is being able to use Scene.send(:"tick_#{args.state.scene}", args), but the way the template is set encourages people to put all the scene behavior as methods under Scene. That can cause methods from one scene leaking (or worse, overriding) other scenes! For instance:
# scenes/gameplay.rbmoduleScenedefself.tick_gameplay(args)update(args)enddefupdate(args)endend# scenes/pause.rbmoduleScenedefself.tick_pause(args)update(args)end# this will override the update method in the gameplay scenedefupdate(args)endend
I propose a gentle change (so we can still use send as before), but that namespaces the specifics of each scene. Each scene is still defined in a separate file, with a corresponding tick_#{scene} method. But that method will use an inner module to define its behavior:
# scenes/gameplay.rbmoduleScenedefself.tick_gameplay(args)GameplayScene.tick(args)endmoduleGameplaySceneclass << selfdeftick(args)# do stuffendprivate# you can define private helper methods that don't pollute the Scene namespaceendendend# scenes/pause.rbmoduleScenedefself.tick_pause(args)PauseScene.tick(args)endmodulePauseSceneclass << selfdeftick(args)# do pause stuffendprivate# pause helper methodsendendend
This won't vastly change the template, but it promotes better defaults, IMO. Thoughts?
The text was updated successfully, but these errors were encountered:
Makes a ton of sense, I think that’d be great! Let me know if I can do anything to help support the change—contribution certainly welcome. Glad Scale has been helpful. 🙌
Hey! Thanks for creating Scale! It's been helpful on my first DR game.
One thing that didn't please me was how all the game Scenes had to live inside the same scope. I understand how handy is being able to use
Scene.send(:"tick_#{args.state.scene}", args)
, but the way the template is set encourages people to put all the scene behavior as methods underScene
. That can cause methods from one scene leaking (or worse, overriding) other scenes! For instance:I propose a gentle change (so we can still use send as before), but that namespaces the specifics of each scene. Each scene is still defined in a separate file, with a corresponding
tick_#{scene}
method. But that method will use an inner module to define its behavior:This won't vastly change the template, but it promotes better defaults, IMO. Thoughts?
The text was updated successfully, but these errors were encountered: