Create and sell game packs

Game Packs are a handy way to add more interesting play to a game. In Whirled, there are two types of game packs: item packs and level packs. Item packs are used to grant player items in game, such as a magic hat, and level packs usually provide additional levels for the game.

The game packs are also a great way for game creators to monetize their game. The Whirled SDK contains methods that a game can use to display its shop during gameplay and also react to the purchase of game items in game. This way, the purchase event is minimally intrusive to the flow of the play.

This tutorial will cover the creation and integration of the game packs into a game, and how to sell these packs.

Note: Once you add an item or game pack to the Item Packs or Game Packs tabs in the game editor, you cannot delete them.

Creating Your Game Pack
Game packs (level/item packs) can be anything from a text file to an actual SWF file containing all the content for that level. You can use the idea of packs to break your game into smaller, more easily downloadable pieces, or you can just use the packs as markers to check if the player is allowed to access certain content in your game.

Scenario 1: Breaking up the game into smaller pieces
An example of the game that does is Underwhirled Drift. It breaks up the game into multiple level packs and only downloads the necessary content when the user reaches the next level.

Scenario 2: Using packs as markers
I create a game which contains all the content for the game. I upload a game pack which is simply a text file. When the player reaches a new level in the game, the game checks to see if the player has the text file. If they do, then the game allows them to proceed to the next level.

Local Testing
In order to use gamepacks while testing on your PC do the following:


 * In the whirled directory there is a "dist" directory, you must place your packs in there.
 * Edit your game's config.xml file (create the file in game's directory if it doesn't already exist) to point to your level packs. It should look something like this:

 

You can have any directory structure you like as long as the file exists somewhere under dist.

When editing XML files be aware that some editors insert invisible characters at the beginning, which will result in parsing errors.

Uploading Your Game Pack

 * 1) Choose Games &rarr; My Games to see the Games you own.
 * 2) Click the Edit link under the game you want to make a game pack for.
 * 3) Select either the "Item Packs" or "Level Packs" tab.
 * 4) Click on the "Create" button to get the game pack creation interface. [[Image:Stuff-Create_item_pack.png|none|thumb|400px|Item pack interface. The level pack creation interface looks similar, but says level instead of item and has the premium checkbox optional.]]
 * 5) Click on the Name field and enter a name for your item or level pack. This is the name that is displayed under the item or level pack if it is sold in the shop. It will also be used on the Item or Level Pack tab when you edit your game.
 * 6) Click on the Identifier field and enter an identifier for your item or level pack. This string is used to identify this item or level pack in your game code. For the example code shown above, the level pack source identifiers are mus_night and mus_day.
 * 7) If you are creating a level pack, you have the option to make it premium. Premium level packs must be purchased by the player, non-premium packs are available to all players.  Item packs are required to be premium (must be purchased).
 * 8) Click Upload a new file in Item or Level Pack Media and find the file for your item or level pack. This can be anything from a text file, graphics, SWFs, MP3s.
 * 9) Click Upload a new file in Thumbnail and find the image file to represent your item or level pack (png, jpg or gif; max. 80x60, larger images will be scaled down). This is the image that will be seen in the player's stuff page or in the shop. It will also be used on the Item or Level Pack tab when you edit your game.
 * 10) Click on the Description field and enter a description of your item or level pack. This is only required if you plan to sell it in the shop.
 * 11) Confirm that you own the copyrights to the item or have authorization to upload it.
 * 12) You can then click on Save to add your item or level pack to the Item or Level Pack tab.

After the upload, you should have something like this:



Listing Your Game Pack
Listing the game pack is similar to listing any other item in the shop. However, the main game has to be listed before any game packs can be listed. Go to the Item or Level Packs tab and click on "list" for the pack you wish to list. This will give you a popup with the listing screen to fill out with the desired options that are outlined here.

''NOTE: Even if you are not planning to sell your pack for coins/bars (premium), you still have to list the item in order for other players to have access to it. In that case, you will use the "Hidden" option under Strategy on the listing screen.''

Coding the Game Pack into a Game
To get a list of all the game packs and items packs available to your game, you can call getLevelPacks and getItemPacks on the GameSubControl object.

gameCtrl.game.getLevelPacks; or gameCtrl.game.getItemPacks;

This call will return an array of objects containing:

ident - string identifier of item pack (This is the same string that you specified during the pack upload) name - human readable name of item pack mediaURL - URL for item pack content premium - boolean indicating that content is premium or not

For level packs, there are some convenience code in the contrib section (LevelPacks & LevelPackManager) that helps you parse and manage the arrays.

import com.whirled.contrib.LevelPackManager; .... public static var allLevelPacks :LevelPackManager = new LevelPackManager; allLevelPacks.init(gameCtrl.game.getLevelPacks);

There currently is no equivalent convenience code for item packs, but you can easily write something similar and contribute it.

In case you need to load packs directly from your server agent (which cannot use sockets) you can call the loadLevelPackData and loadItemPackData functions on the GameSubControl object.

Showing the Shop during Game Play
While a user is playing a game, it is possible to figure out what game packs they have and do not have, and then display an upsell.



When the user clicks to buy an item, you can then open up a shop page to the left of the game screen.



To open up the LevelPacks Game Shop with all level packs for sale for your game: var gameCtrl :GameControl = new GameControl(this); gameCtrl.local.showGameShop(GameControl.LEVEL_PACK_SHOP);

To open up the Item pack Game Shop displaying details for an item pack with catalogID of 555:

var catalogID :int = 555; gameCtrl.local.showGameShop(GameControl.ITEM_PACK_SHOP, catalogID);

'''You can obtain the catalog ID when you list your item/level pack. For example the catalog ID of the following level pack http://www.whirled.com/#shop-l_11_99 is 99'''.

You can also open up other shop pages other than the ones shown here (such as avatars or furniture) by changing the itemType parameter on showGameShop, valid shop constants are defined on the GameControl. Learn how to list other items in your game shop.

Checking Player Pack Content
To listen for when someone buys an item pack (that they don't already own) for your game while inside your game, you can register to listen for the PLAYER_CONTENT_ADDED event.

gameCtrl.player.addEventListener(GameContentEvent.PLAYER_CONTENT_ADDED, playerContentAdded);

protected function playerContentAdded (event :GameContentEvent) :void {   // event.contentType will either be ITEM_PACK or LEVEL_PACK // event.contentIdent will be the "ident" string for the pack they bought if (event.contentType == GameContentEvent.ITEM_PACK) { gameCtrl.game.systemMessage("player " + event.playerId + " bought the item pack with id " + event.contentIdent); }

You can also get a list of the packs that a player currently owns by calling getPlayerItemPacks(playerId:int) or getPlayerLevelPacks(playerId:int) on the PlayerSubControl.