First, I’d like to apologize for my brief hiatus over the past month — I upgraded to a new computer, and Flash was out of commission for a while. But assuming you haven’t abandoned this site yet, here’s the next part of the side scrolling series.
Last tutorial pretty much finished up the bare-bone mechanics and visuals of a basic platformer. So I figured with this tutorial we’d start adding various extra features to spice up the game. This time, we’re adding a collectible key to the level, as well as a locked door which it will open. This door might be the end of one of your levels, which in turn might load a new level afterwards (although we aren’t coding multiple levels in this tutorial — just the door and key which will allow for this in the future).
Make sure you’ve read up through Part 6 of the series.
One thing you want to do as a game developer is make your players want to come back to your game more than once. And one of the best ways to accomplish this is to enable them to save their data for persistent gameplay. You might expect saving and loading to be tough to implement, but actionscript 3 is helpful enough to include the powerful SharedObject, which makes saving and loading data a piece of cake.
In this tutorial, we will create the following demo. Click the “+1” button a few times to add to your score. If you refresh this webpage without clicking the “save” button, your score will revert to 0 when the page loads. But if you do click the “save” button, your score will load automatically the next time you load the page. Try it out!