FrameworksGamesCocos Creator

Using Playroom Kit with Cocos Creator

Cocos Creator is a 2D/3D game engine that supports JavaScript and TypeScript. You can use Playroom Kit with Cocos Creator to build multiplayer games.

Setup

Follow these steps to import Playroom Kit into your project.

  • Create a new project in Cocos Creator.

  • Get a multiplayer.full.umd.js and types.d.ts (rename to playroom.d.ts for visibility) file into your project (newer versions of Cocos Creator default to TypeScript).

  • Import the multiplayer.full.umd.js as a plugin

Cocos Creator Project Settings
  • Now you can start using Playroom Kit in your Cocos Creator scripts like this:
import * as PlayroomType from './playroom.d.ts';
const Playroom: typeof PlayroomType = window.Playroom;
 
export class MyScript extends Component {
 
    async start() {       
        await Playroom.insertCoin({
            // any options here
        });
    }
}