Need state management? Need a simple way to get objects on and off the screen? Need those objects to respond to click and keyboard events? Have no fear StageManager is here!
A few days/weeks ago we released our first version of LoveTank. When we did, we wanted to include a way to select which tanks participated in the battle, but we had not coded enough to have created forms or buttons or other common UI controls. So we asked the question Concept of a button?, and many people provided examples and suggestions, thank you again all. At first, I missed some of the details of what people were sharing with me, but as time went by I began to understand more of the what and why.
Then I was tasked at work to fix another persons code in AS3. The action script project needed the same kind of things that my Love2D project needed. Stage management, moving scenes on and off the stage, controls (that could highlight, be clicked on, have behavior), etc. Because Love2D is quick to prototype in, we sat down and wrote that framework we needed for AS3 in LoveTank.
We ported our Lua into AS3 and it worked great in both languages, so we decided to create this thread to explain the framework. For those coming from other languages this is the "rails" part of Ruby on Rails or the automatic wiring of MVC components in the MVC for ASP framework.
In short this micro-architecture is made up of a handful of classes, described below:
AppManager: State management for the application and the guy you ask to display a form/scene.
StageManager: Behind the scenes manager of how things get on and off the stage. Generally only called by the AppManager and Love2D callbacks.
[Named]Controllers: The class that provides all the logic for the current scene/controls on the stage/screen. We did build this so multiple controllers could have items on the stage at the same time (like a BackgroundController and a FarmController, for example).
[Named]Mediators: Façade layer for Business Logic. Would likely be who you called to start any threaded operations.
StageManager for LÖVE
StageManager for LÖVE
- Attachments
-
- LoveTank.love
- (22.02 KiB) Downloaded 206 times
Re: StageManager for LÖVE
Isn't it just easier left to a simple variable named state?
Like object.state = "display"
if object.state ="no-display"
destroy_object();
end
but I'm sure this is much more complex, and certainly helps if you're managing 100s of te same object.
Like object.state = "display"
if object.state ="no-display"
destroy_object();
end
but I'm sure this is much more complex, and certainly helps if you're managing 100s of te same object.
Who is online
Users browsing this forum: RagingDave and 3 guests