Today was definitely the day to organize the city screen. Given a city that was cut off (in code) from the rest of the world (still in code), I got the work I needed to display an asset selection menu in order to build a 3x3 grid of cities. When the asset was clicked, it would remain highlighted and the asset would be used to make a city. There's a nifty little thing where one can access frame states (up, over, down, hit) in a SimpleButton object, so it's as simple as saving the up state and switching it with the over state, right?
NOPE. Dead wrong. In fact, one of the consequences (that the Internet and Google are ill prepared for) when it comes to externally loading movie clips as buttons is that those states are then nulled. The button works as it should, but those states can't be switched. Not too much to work around that, to be honest. Although it is a bit of overhead, I quickly rounded up some separate buttons with their corners highlighted like the over state and only set them to display on the screen (addChild) over the actual buttons when selected. This also came in handy when finishing up the roads, as I could add and switch children (such as roads) to be under more topside objects as they were being drawn on the scene (topside being intersections).
What next? The City structure needed quite the overhaul, so I set it to be an array of (no longer abstract Building classes), where each building instead answered to an enum. It may require some unwieldy switch statements, but with time not being on the side of those who prototype, it did the job. After some magical uses of the Observer pattern to be able to update parent classes with their children's data, I found a way not only to build cities from assets, but to save and load them when the cityScreen is entered.
What next? Some massive integration is about to be done, as I am just about to hit the world level in terms of accessing cities, and the cities themselves also need to apply their various effects that are attached to each building (...thing. Forgive me, the placeholder art has its purpose but not for long). To the design document!
No comments:
Post a Comment