Cocos Creator 3.0 with Nakama

Hello everyone ,
i want to use Cocos Creator 3.0 to make a multiplayer FBinstant game , i want to achieve this using Nakama server .

i have installed Nakama in my Cocos Project using npm i @heroiclabs/nakama-js ,
the issue is since Cocos Creator 3.0 supports only Typescript , how can i access to Nakama js API using Typescript .

@mofirouz

NPM is not supported currently. It will be supported in 3.0 RC. You may use this library now by:

  • Grab the dist files of that library into project assets folder.
  • Open editor, select the dist file(s) and check Load as plugin, Load in editor, Load in preview in inspector.
  • Use global variables to access that library.
2 Likes

Thank you @shrinktofit for the assist , i really appreciate it .

Most of the Nakama api dist Files are in Typescript, i couldn’t fin an option to load these file as plugin

instead i have imported the other js files as plugin :

image

image

This is the dist folder :
image

i can do something like

var client : Client = new Client("defaultkey", "127.0.0.1", "7350",false);

Without getting any types errors but when i run the game , i get these error :

image

I have fixed this by adding only nakama-js.umd.js to the assets folder and importing the script as plugin

Cocos_Creator_-cocos-nakama-_dbassetssencet_04January2021_05_527

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.