Commit c7c4ac86 by Shawn Wang

add platform

parent 6983c1f2
node_modules/ node_modules/
.wing/ .wing/
fe_wxgame/
\ No newline at end of file
fe_wxgame/*
!fe_wxgame/platform.js
\ No newline at end of file
...@@ -15,7 +15,7 @@ class SceneManager extends egret.DisplayObjectContainer { ...@@ -15,7 +15,7 @@ class SceneManager extends egret.DisplayObjectContainer {
this.roomScene = new RoomScene(); this.roomScene = new RoomScene();
this.gameScene = new GameScene(); this.gameScene = new GameScene();
// 默认添加开始场景 // 默认添加开始场景
this.addChild(this.roomScene); this.addChild(this.gameScene);
} }
// 实例化单例获取方法 // 实例化单例获取方法
public static getInstance(): SceneManager { public static getInstance(): SceneManager {
......
/**
* 请在白鹭引擎的Main.ts中调用 platform.login() 方法调用至此处。
*/
class WxgamePlatform {
name = 'wxgame'
login() {
return new Promise((resolve, reject) => {
wx.login({
success: (res) => {
resolve(res)
}
})
})
}
getUserInfo() {
return new Promise((resolve, reject) => {
wx.getUserInfo({
withCredentials: true,
success: function (res) {
var userInfo = res.userInfo
var nickName = userInfo.nickName
var avatarUrl = userInfo.avatarUrl
var gender = userInfo.gender //性别 0:未知、1:男、2:女
var province = userInfo.province
var city = userInfo.city
var country = userInfo.country
resolve(userInfo);
}
})
})
}
connectSocket(options){
wx.connectSocket(options)
}
onSocketOpen(callback){
wx.onSocketOpen(callback)
}
onSocketClose(callback){
wx.onSocketClose(callback)
}
onSocketMessage(callback){
wx.onSocketMessage(callback)
}
onSocketError(callback){
wx.onSocketError(callback)
}
sendSocketMessage(options){
wx.sendSocketMessage(options)
}
request(options){
wx.request(options)
}
}
window.platform = new WxgamePlatform();
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment