Currency

Overview

The page shows an in-game currency wallet and two buttons that deposit into it. GS2-Money2 keeps currency granted for free and currency the player paid for as separate balances, so you can see which balance moves depending on the button you press. Every reading and button on the page is a UI component generated from the package; no demo-specific script is involved.

How to try it

  1. Your coins shows Free balance, Paid balance, and Total balance.
  2. Press Deposit under Get coins (labeled Deposit 100 free coins); Free balance and Total balance go up by 100.
  3. Press Deposit under Get paid coins (labeled Deposit 50 paid coins); Paid balance and Total balance go up by 50. This deposit is recorded as a purchase for 120 JPY.

The wallet is shared by every showroom demo, so currency spent in other demos such as the shop is reflected in the balances here.

GS2 services used

  • GS2-Money2: A GS2-Money2 wallet holds the free and paid balances separately. A paid deposit is recorded with a price and a currency code, which keeps it apart from free deposits.
  • GS2-Exchange: Two GS2-Exchange rates define the transactions each Deposit button runs to deposit into GS2-Money2, executed server-side automatically.

Use it in GS2 Studio

In GS2 Studio’s Simple mode, open Add features and press Add on Currency to bring this feature into your own project. To point at the package directly, choose Add from GitHub and enter the package below.

https://github.com/gs2io/gs2-studio-package/tree/main/foundation-economy-currency/packages/foundation-economy-currency
  • Owner: gs2io
  • Repository: gs2-studio-package
  • Subdirectory: foundation-economy-currency/packages/foundation-economy-currency

Source code