Blackberry Messenger Bedienungsanleitung Seite 4

  • Herunterladen
  • Zu meinen Handbüchern hinzufügen
  • Drucken
  • Seite
    / 11
  • Inhaltsverzeichnis
  • LESEZEICHEN
  • Bewertet. / 5. Basierend auf Kundenbewertungen
Seitenansicht 3
http://cmer.uoguelph.ca 4
This function is used to reset the board, and initialize all variables. The first thing that
will need to be added to this function is to initialize the variables we just created. Add the
following lines to the top of the function in the JavaScript file.
//Reset the number of tries counter
triesCounter = 0;
//Reset the win,lose,tie counters
userWins = 0;
userLoses = 0;
userTies = 0;
When the user exits the application, we want their BBM profile to be updated with their
statistics from the last games that they played. In order to do this, we must change the
callback function for the BlackBerry system event onHardwareKey. The callback
function currently looks like the following:
blackberry.system.event.onHardwareKey(blackberry.system.event.KEY
_BACK, function ()
{
blackberry.app.exit(); //Exit the application
});
What we want to do instead is update the BBM profile item for this application to show
how many times the user won, lost and tied in the game. Add the following code to the
callback function:
try
{
//Update stats on profile here
var itemText = "Gave up on playing Tic Tac Toe with
"+userWins+" wins, "+userTies+" ties and "+userLoses+ "
loses! ";
var itemIcon = "local:///exclaim.jpg";
var itemOptions = { text: itemText, icon: itemIcon };
blackberry.bbm.platform.self.profilebox.addItem
(itemOptions);
}
catch (e)
{
alert(e);
}
blackberry.app.exit(); //Exit the application
From the code, you can see that we create a variable which holds the message we want to
put inside the profile box. We also include an icon which will go beside the text, and
finally we create a JSON variable called itemOptions which holds both the text and the
location of the icon. Afterwards, we call the addItem function of the Profile Box package
in the BBM SDK to add the text and icon to the package.
Seitenansicht 3
1 2 3 4 5 6 7 8 9 10 11

Kommentare zu diesen Handbüchern

Keine Kommentare