ryltcsjg / pinusCocosCreatorHelloWorld

使用CocosCreator2.0.4建立簡易pinus客戶端連線sample

Home Page:https://demo.newingtech.co.uk/2018/10/25/pinus-cocoscreator-client-sample/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

目的

建立簡單的pinus 可用連線客端sample

本次範例scene名稱為test

測試環境

目前Pinus 可以使用跟Pomelo相同的客端連線方式

Server side : Mac (nodeJs v8.11) / Windows Server 2016 (nodeJS v8.10)

Client: CocosCreator 2.0.4 / Html5 / iOS 12.0/ Android 8.0 (Android Studio 3.2)

pomelo plugin : https://github.com/fuhongxue/CocosCreator-Pomelo-plugin

Server side

參照官方helloworld即可

pinus init ./helloworld
cd helloworld
sh npm-install.sh  # windows 下執行npm-install.bat
cd game-server
npm run build
cd dist
node app

Client Side

下載 CocosCreator 2.0.4

下載 plugin : https://github.com/fuhongxue/CocosCreator-Pomelo-plugin

複製 plugin 裡的 pomelo-creator-client.js 置入 CocosCreator 專案的 Script資料夾內

於上述屬性檢查器中 導入為插件, 同時允許web 以及 允許 native

連線範例:

var pinus = window.pomelo;
var host = "your-server-ip-or-domain";
var port = "3010";
pinus.init({
    host: host,
    port: port,
    log: true
}, function () {
    pinus.request("connector.entryHandler.entry", "hello pinus", function (data) {
        console.log(data.msg);
        that.label.string = data.msg;
    });
});

About

使用CocosCreator2.0.4建立簡易pinus客戶端連線sample

https://demo.newingtech.co.uk/2018/10/25/pinus-cocoscreator-client-sample/


Languages

Language:JavaScript 100.0%