Commit 1caae731 by Shawn Wang

Merge branch 'develop' of cd.i.strikingly.com:shawn.wang/crazyflirt into develop

parents 4ce78deb 4af542f5
......@@ -61,9 +61,12 @@ class Main extends egret.DisplayObjectContainer {
await this.loadResource()
var stage = egret.MainContext.instance.stage;
stage.setContentSize(1334, 750);
this.createGameScene();
await platform.login();
const userInfo = await platform.getUserInfo();
Store.onMessage({
type: 'setUserInfo',
data: userInfo
})
console.log(userInfo);
platform.connectSocket({
......@@ -85,19 +88,25 @@ class Main extends egret.DisplayObjectContainer {
platform.onSocketOpen(() => {
platform.sendSocketMessage({
data: JSON.stringify({
cid: "asnbduawh",
seq: "moving",
x: 100,
y: 123
type: 'entry',
rid: 'default_room',
payload: {
avatar_url: Store.getState().userInfo.avatarUrl,
nick_name: Store.getState().userInfo.nickName
}
}),
success: () => {
success: res => {
console.error("sendSocketMessage success")
},
fail: () => {
fail: res => {
console.error("sendSocketMessage fail")
},
complete: res => {
}
})
})
this.createGameScene();
platform.onSocketMessage(function(res) {
console.log('收到服务器内容:' + res.data)
......
let _state = {
let _state: any = {
role: null,
cid: null,
roomId: null,
}
class Store {
static getState() {
return _state
......@@ -20,6 +21,8 @@ class Store {
roomId: room_id,
}
break;
case 'setUserInfo':
_state.userInfo = message.data
default:
break;
}
......
class RoomScene extends egret.Sprite {
private startLabel: egret.TextField
private players: Array<any>
public constructor() {
super();
this.init()
......@@ -8,9 +11,68 @@ class RoomScene extends egret.Sprite {
// 初始化(给开始按钮绑定点击事件)
private init() {
console.log('RoomScene.init')
this.initBg()
this.initStartLabel()
// platform.sendSocketMessage({
// data: JSON.stringify({
// type: 'entry',
// rid: 'default_room',
// payload: {
// avatar_url: Store.getState().userInfo.avatarUrl,
// nick_name: Store.getState().userInfo.nickName
// }
// }),
// success: res => {
// console.error("sendSocketMessage success")
// },
// fail: res => {
// console.error("sendSocketMessage fail")
// },
// complete: res => {
// }
// })
platform.onSocketMessage(res => {
if (res.type === 'entry') {
console.log('get entry data')
}
})
// this.startLabel.text = "START";
this.startLabel.addEventListener(egret.TouchEvent.TOUCH_TAP, this.startHandler, this);
this.addChild(this.startLabel);
// put display object to this scene
}
private initBg() {
var shape: egret.Shape = new egret.Shape();
shape.graphics.beginFill(0x343E5F);
shape.graphics.drawRect(0, 0, 2000, 2000);
shape.graphics.endFill();
this.addChild(shape);
var bg: egret.Bitmap = new egret.Bitmap()
bg.texture = RES.getRes("logo_jpg")
bg.scaleX = bg.scaleY = 2
bg.x = 1334 / 2 - 280
bg.y = 100
this.addChild(bg)
}
private initStartLabel() {
this.startLabel = new egret.TextField()
this.startLabel.textColor = 0xF0D66D
this.startLabel.text = "请稍等..."
this.startLabel.width = 200
this.startLabel.anchorOffsetX = 100
this.startLabel.x = 1334 / 2
this.startLabel.textAlign = egret.HorizontalAlign.CENTER;
this.startLabel.y = 1136 / 2
}
private startHandler() {
console.log('starthandler')
SceneManager.getInstance().changeScene('gameScene');
}
public release() {
// 移除事件
}
......
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