I write that title mostly in jest, but I did make a component that actually worked right the first time. Instances like this aren't all that common in software development. So, I'm actually quite happy about my latest success.
I was trying to think of what other programming I could do for the game and thought of a component that I could use to show the points that a combo earned. I wanted something general enough to be reused in other contexts. So, I gave the component, which I called TemporaryText, all sorts of parameters. I was even feeling particularly inspired by jQuery and made some of the parameters able to be either numbers or objects with multiple numbers, which was a moderate pain but it provides a great deal of flexibility and ease of use.
I drew from the screen manager component in setting the transitions and defaults of the parameters. My proof of concept code fades in a message that says "Click!" wherever the user clicks. Then it animates the text up into the top left corner of the screen and then fades out. I was mostly expecting some sort of crash to happen because of the complicated transitions, but apparently I was thinking clearly.
I separated the animation into three stages. In the start() function, which is the only public function of the class, the object adds itself to a DisplayObjectContainer and does the "in" transition based on the type that the user set. When that transition is done, the object calls the move() function, which moves the text to the ending position. When that transition is done, the object calls the finish() function, which does the "out" transition, also set by the user, and removes itself from the DisplayObjectContainer.
I didn't have time tonight to integrate this into the game, but I expect that it'll go fairly easily. Anyway...yay for quick success!
No comments:
Post a Comment