| |  |
Home In This Issue Email a Friend EasyPrint
 | |
|
PROGRAMMING POWER
Setting application preferences
By Alan Jay Weiner
Last month I started writing a small game for my son. This month we'll add a couple of small features and allow some configurability. Configurations should be "sticky" -- they should remain set until we change them, even if we run other programs and then return to the original application.
Palm applications use "preferences databases" to store these kinds of user configurations. Applications may store a small amount of data as a preferences record. They retrieve that data when they start, they store it when they exit. Having everyone use the same database saves each application from creating a special database just for their user configurations and provides a uniform method for applications to preserve configuration data between runs.
Changes to rocketship Before we get into how to use preferences, lets take a quick look at what I changed in Rocketship.
First, I added a few definitions in the beginning, including the Creator ID. I'll speak about that in a moment.
Second, I added a menu to allow configuring the vertical speed. At the same time, I changed SetPrelaunch and LaunchRocket so they set vertspeed from the configured speed (cfg_vertspeed) at launch time rather than pre-launch. SetPrelaunch occurs after the rocket hits the top, at the end of the game (such as it is). If you play a game, and then change the speed, it wouldn't take effect on the next game since that game's speed was already set. Setting vertspeed at launch time fixes this problem.
I also fixed two bugs. The first allowed tapping the screen to make the rocket go faster. It decremented vertspeed for each tap, but it allowed it to go below zero. This should've caused problems, but didn't because of the second bug. That one failed to use vertspeed as a counter at all! If you look at RedrawRocket from last month's listing, I never updated lastmovetime. So after the first movement delay, the rocket was going full speed! Oops...RedrawRocket now updates the lastmovetime value.
This had an interesting effect. It turns out that the value I picked for the initial time delay was way too slow. I've changed these so they range from 0 (fast) to 10 (very slow).
[ Next ]
|
|
-- Advertisement --
EASY DEDICATED AND VIRTUAL DEDICATED SERVERS FOR AS LOW AS $67.99 PER MONTH
Customize and configure your own dedicated server. Simply choose one of our popular plans or select your own Linux or Windows server and plan options.
NO LONG WAITS. Server provisioned within hours.
Tap here now and be up and running with your own server tonight. |
-- Advertisement --
CLEARSYNC - THE BETTER SHARING CALENDAR
ClearSync is wherever you are.
Access your account from:
- Your PC, Mac, or Linux machine
- Your Palm OS handheld
- Any online browser
ClearSync works even without Internet access.
ClearSync tracks and saves your changes on your computer, so you're not stranded like with most online calendars.
Tap here to get your life in sync FREE for 30 days! |
Copyright © 1998-2008, ZATZ Publishing. All rights reserved worldwide.
|