Commit a8f4e7df by Mike Zhu

房间里准备增加头像

parent 6d265e88
...@@ -2,6 +2,7 @@ class RoomScene extends egret.Sprite { ...@@ -2,6 +2,7 @@ class RoomScene extends egret.Sprite {
private startLabel: egret.TextField private startLabel: egret.TextField
private players: Array<any> private players: Array<any>
private playerContainer: egret.DisplayObjectContainer
public constructor() { public constructor() {
super(); super();
...@@ -13,8 +14,10 @@ class RoomScene extends egret.Sprite { ...@@ -13,8 +14,10 @@ class RoomScene extends egret.Sprite {
console.log('RoomScene.init') console.log('RoomScene.init')
this.initBg() this.initBg()
this.initStartLabel() this.initStartLabel()
this.initPlayerContainer()
this.addChild(this.startLabel); this.addChild(this.startLabel);
// var sound: egret.Sound = RES.getRes("catched_0_mp3");
// sound.play();
// put display object to this scene // put display object to this scene
} }
...@@ -22,14 +25,7 @@ class RoomScene extends egret.Sprite { ...@@ -22,14 +25,7 @@ class RoomScene extends egret.Sprite {
switch (data.type) { switch (data.type) {
case 'entry': case 'entry':
const payload = data.payload const payload = data.payload
if (payload.seat == 0) { this.updateStartLabelAndPlayers(payload)
this.startLabel.text = '开始'
this.startLabel.touchEnabled = true
this.startLabel.addEventListener(egret.TouchEvent.TOUCH_TAP, this.startHandler, this)
} else {
this.startLabel.text = '等待房主点击开始'
this.startLabel.touchEnabled = false
}
break; break;
case 'game_ready': case 'game_ready':
this.countDown(payload) this.countDown(payload)
...@@ -39,6 +35,18 @@ class RoomScene extends egret.Sprite { ...@@ -39,6 +35,18 @@ class RoomScene extends egret.Sprite {
} }
private updateStartLabelAndPlayers(payload) {
if (payload.seat == 0) {
this.startLabel.text = '开始'
this.startLabel.touchEnabled = true
this.startLabel.addEventListener(egret.TouchEvent.TOUCH_TAP, this.startHandler, this)
} else {
this.startLabel.text = '等待房主点击开始'
this.startLabel.touchEnabled = false
}
const members = payload.members
this.addChild(this.playerContainer)
}
private countDown(res) { private countDown(res) {
this.startLabel.text = '3' this.startLabel.text = '3'
const timer = setInterval(() => { const timer = setInterval(() => {
...@@ -77,6 +85,11 @@ class RoomScene extends egret.Sprite { ...@@ -77,6 +85,11 @@ class RoomScene extends egret.Sprite {
this.startLabel.textAlign = egret.HorizontalAlign.CENTER; this.startLabel.textAlign = egret.HorizontalAlign.CENTER;
this.startLabel.y = 1136 / 2 this.startLabel.y = 1136 / 2
} }
private initPlayerContainer() {
this.playerContainer = new egret.DisplayObjectContainer()
this.playerContainer.width = 600
this.playerContainer.height = 200
}
private startHandler() { private startHandler() {
console.log('starthandler') console.log('starthandler')
......
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