GamePix Plugin for Godot 4.xx

1. Tutorial

A full video tutorial covers the whole integration process, from project setup to publishing.

2. Installation

Download the plugin archive and extract it into addons folder of your game.

Folder structure:

Code
- game-folder
  - addons
    - gpx-godot-plugin
      - index.html
      - plugin.cfg
      - plugin.pd
      - gpx.gd

Once this is done:

  • Open Project -> Project Settings
  • Activate Plugins tab
  • Enable gamepix-sdk plugin:
  • Gamepix plugin installed and enabled in godot.png
  • Reload project Project -> Reload Current Project

3. Exporting game for GamePix

  • Open the Export... dialog
  • Select GamePix preset
  • Please ensure to set the name of the output file as "index.html" in the dialogue box:
  • export file name index.html
  • Export game using this preset and publish zip archive on GamePix:
  • export file name index.html

4. Using SDK

In your scripts, you will be able to use GPX object to interact with the platform.

For example, let's declare function that handles key events and run GamePix Ads.

5. Interstitial AD

Code
func _input(ev):
	if ev is InputEventKey and ev.keycode == KEY_I and not(ev.is_pressed()):
		print("Interstitial AD started")
		GPX.interstitialAd(Callable(self, "onInterstitialComplete"))

func onInterstitialComplete():
	print("Intersitital AD completed")

When you press the "I" key, interstitial ads will be displayed, and you will see the corresponding output in the console.

Code
Interstitial AD started
Intersitital AD completed

6. Resume/Pause game

When the interstitial/reward ad is active, you must pause the game and sounds. The plugin should do this automatically, but if it's not working for you, please refer to the Godot pause/resume documentation.

7. Rewarded AD

Code
func _input(ev):
	if ev is InputEventKey and ev.keycode == KEY_R and not(ev.is_pressed()):
		print("Reward AD started")
		GPX.rewardAd(Callable(self, "onRewardSuccess"), Callable(self, "onRewardFail"))

func onRewardSuccess():
	print("Reward AD succeed")

func onRewardFail():
	print("Reward AD failed")

When you press the "R" key, reward ads will be displayed, and you will see the corresponding output in the console.

Code
Reward AD started
Reward AD succeed (or failed)

8. Other methods

GPX.lang() - gets the current preferred language by the player

GPX.updateScore(score) - should be called immediately every time the current score is updated

GPX.updateLevel(level) - should be called to send the score after the player passed the level

GPX.happyMoment() - should be called when Happy Moment just happened

GPX.setItem(key, value) - Persistently stores the value. The value must be a string.

GPX.getItem(key) - Read value from storage.

9. Game background

You can add custom background while game is loading, to do this please put background.jpg into root of exported game