You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The client uses TypeScript with Cocos Creator. It would be great if a unified schema definition file could also be used on the client side. This way, I can have a consistent code suggestion experience.
// server: part of GameRoomState.ts class
export class GameRoomState extends Schema {
}
// cocos client: fake type define
export type GameRoomState = Schema & {
players: MapSchema;
gameState: GameState; // 初始状态为准备
} // ugly code, and no use...
This idea came up while coding an AI bot for a game. I tried to import the Colyseus client code on the server side (using npm install --save colyseus.js), logging in and entering the room in the same way as the client, and simulating all the normal client operation logic. The development experience was excellent, and I was even able to use the same GameRoomState file during development, which provided complete code suggestion functionality. So I was thinking about how to achieve a similar process in Cocos Creator, allowing for direct usage of definitions like export class GameRoomState extends Schema {}
The text was updated successfully, but these errors were encountered:
HI @wang-yichun, I believe you can import only the type directly from the backend into your Cocos Creator project by using import type, please let me know if that works for you:
// In Cocos Creatorimporttype{GameRoomState}from"../../location-of-your-backend-project/GameRoomState";
The client uses TypeScript with Cocos Creator. It would be great if a unified schema definition file could also be used on the client side. This way, I can have a consistent code suggestion experience.
// server: part of GameRoomState.ts class
export class GameRoomState extends Schema {
}
// cocos client: fake type define
export type GameRoomState = Schema & {
players: MapSchema;
gameState: GameState; // 初始状态为准备
} // ugly code, and no use...
This idea came up while coding an AI bot for a game. I tried to import the Colyseus client code on the server side (using npm install --save colyseus.js), logging in and entering the room in the same way as the client, and simulating all the normal client operation logic. The development experience was excellent, and I was even able to use the same GameRoomState file during development, which provided complete code suggestion functionality. So I was thinking about how to achieve a similar process in Cocos Creator, allowing for direct usage of definitions like export class GameRoomState extends Schema {}
The text was updated successfully, but these errors were encountered: