Wizard Fu's Cocos2dx Platformer Game Engine v1.0.1

nat@wizardfu.com

See the file LICENSE for the license governing this code.

#pragma once
#include "Kit.h"

Store makes it easy to use Soomla to keep an inventory of virtual currencies, virtual goods and packs, equippable items, and also to make in-app purchases (IAP) in a cross-platform way.

For details on Soomla, check out the cocos2dx-store project’s readme.

Currencies

The types of virtual currencies used by this game.

const char* const kCurrencyIdGold = "currency_gold";

Events

Event types that will be triggered via cocos2d::NotificationCenter when certain things happen with the store.

const char* const kEventCurrencyBalanceChanged = "onCurrencyBalanceChanged";
const char* const kEventGoodBalanceChanged = "onGoodBalanceChanged";
const char* const kEventGoodEquipped = "onGoodEquipped";
const char* const kEventGoodUnequipped = "onGoodUnEquipped";
const char* const kEventGoodUpgrade = "onGoodUpgrade";

Store

A statically-implemented singleton object exposing a few of Soomla’s methods. For more control over items, equippables, packs and more, use soomla::CCStoreInventory.

Browse the cpp file for an overview of how to implement Soomla.

class Store
{
	public:

Create and initialize the store and assets. Register for event handling.

		static void create();

Return the balance of an item.

		static int getItemBalance(const string& itemId);

Give or take an amount for the given item. Positive values give. Negative values take.

		static void giveItem(const string& itemId, int amount);

Buy the given item id.

		static void buyItem(const string& itemId);
};
 
h