Play the games, create the levels

BonusLevel docs, Game API

Checkout our iPhone & iPad games!

GameManager.as, specific functions

  blPlayLvl ( data: as2 String as3 ByteArray , official: Number )

  From the BL API to the game.

When this method is called, you are supposed to unserialize the data (contained in data) and to start playing the level corresponding to this data.

official may contain 4 different values. This parameter might be useful only when the game manages resources (gold, items, powerups, lives etc...) from a level to another (implementing the "User data management", see below).

  • -1 : The level is in test (being currently edited by the player). Your game engine could allow (for example) some cheats in this case to make the level testing more friendly.
  • 0 : The level is not official.
  • 1 : The level is official and has never been successfully completed by the player. In that case, it's safe to take into account resources (powerups, items, lives, etc...) gained or lost by the player during the game.
  • 2 : The level is official but the player has already completed it once. In that case, some games might choose not to take into account resources (powerups, items, lives, etc...) gained or lost by he user during the game.

Advanced : If the level data is very heavy to unserialize, it might be interesting to split the workload over several frames not to stop the animations arounds (animations of the BL graphics interface).


  lvlCompleted ( completed:Boolean , score:Number )

  From the game to the BL API.

This function must be called after the player has completed the current level. When completed is true, the BL interface propose to play the next level. Actually calling this function with completed equal to false, will result in playing again the same level.

  • If completed is true, that means the level has been succesfully completed. If you're using locked levels (that need to be successfully completed to go to the next level), you should always call this method with completed equal to true.
  • score is an integer containing the score achieved by the player on the current level.

  blCatWin ( )

  From the BL API to the game or the editor.

Optional, The method is called when the player has completed all the levels of one of the categories you has configured for your game. You can show, for example, an animation to reward the player.

  blWin ( )

  From the BL API to the game or the editor.

Optional, The method is called when the player has completed all the levels of the game. You can show, for example, an animation to reward the player.



User data management - Optional

The game engine can implement (or not) the "User data management".
What is it ? For example, when a player completes a level, it might be interesting to keep in memory the newly acquired items, gold coins, powerups, to use them later in the next levels. On this purpose, the game engine must save the user data each time they are modified (at the end of a level, or after the player buys items in a shop etc...). When the game implements the "User data API", the player can quit the game safely, his/her progression, resources, items, gold, lives etc... are saved and will be restored when coming back to the game. The methods hereafter are those used by the game engine to save/restore the user data. The user data are saved on BL servers for logged in players or on the local computer otherwise.

  requestUserData ( )

  From the the game to the BL API.

A game implementing the "User data management", should call this function right after the game is loaded. This informs the BL API that we want to receive the current player data and also the new player data each time the player slot changes (player 1, player 2 etc...).

  blNewUserData ( res: Boolean , data: as2 String as3 ByteArray )

  From the BL API to the game.

This method is called by the API if you have subscribed to player data notification. It's called the first time after you call requestUserData() and then each time the player slot changes( player 1, player 2 etc...)

  updateUserData ( data: as2 String as3 ByteArray )

  From the the game to the BL API.

The game engine call this method to save the serialized user data, after a level is successfully competed for example. The user data is only depending on your game but, usually, the new items, powerups, etc..., acquired during a level should be saved only if it is an official level and the first time the player complete it. You can understand now the goal of the official parameter in the blPlayLvl method described above.

  userDataUpdatedCbk ( res: Boolean , data: String )

  From the BL API to the game.

The callback of the updateUserData call. If res==true, the user data was successfully stored, otherwise, data contains an error message.

Our free flash games   Games for your site   Games for your iPhone   Contact   Twitter @jpsarda & @bonuslevelorg