Commit 22c4134b by Shawn Wang

a

parent e0257e72
class Avatar extends egret.Sprite { class Avatar extends egret.Sprite {
public constructor(userData) { public constructor(userData, showName) {
super() super()
this.init(userData) this.init(userData, showName)
} }
private avatar = new egret.Bitmap() private avatar = new egret.Bitmap()
private bg = new egret.Bitmap() private bg = new egret.Bitmap()
private imageLoader = new egret.ImageLoader() private imageLoader = new egret.ImageLoader()
private nameLabel = new egret.TextField()
private init(userData) {
private init(userData, showName) {
this.bg.width = 100 this.bg.width = 100
this.bg.height = 100 this.bg.height = 100
this.bg.texture = RES.getRes("avatar_bg_jpg") this.bg.texture = RES.getRes("avatar_bg_jpg")
...@@ -23,6 +25,16 @@ class Avatar extends egret.Sprite { ...@@ -23,6 +25,16 @@ class Avatar extends egret.Sprite {
this.imageLoader.load(userData.avatar_url || "http://www.insajderi.com/wp-content/uploads/2018/01/asdja.jpg") this.imageLoader.load(userData.avatar_url || "http://www.insajderi.com/wp-content/uploads/2018/01/asdja.jpg")
this.addChild(this.avatar) this.addChild(this.avatar)
if(showName){
this.nameLabel.text = userData.nick_name
this.nameLabel.width = 100
this.nameLabel.textAlign = egret.HorizontalAlign.CENTER;
this.nameLabel.x = 0
this.nameLabel.size = 16
this.nameLabel.y = 100
this.addChild(this.nameLabel);
}
} }
private loadCompleteHandler() { private loadCompleteHandler() {
......
class AvatarGroup extends egret.Sprite { class AvatarGroup extends egret.Sprite {
public constructor(userDatas) { public constructor(userDatas, showName = false) {
super() super()
this.init(userDatas) this.init(userDatas, showName)
} }
private init(userDatas) { private init(userDatas, showName) {
userDatas.forEach((userData, index) => { userDatas.forEach((userData, index) => {
let avatar = new Avatar(userData) let avatar = new Avatar(userData, showName)
avatar.x = index * 100 avatar.x = index * 100
this.addChild(avatar) this.addChild(avatar)
}) })
......
...@@ -16,14 +16,13 @@ class GameScene extends egret.Sprite { ...@@ -16,14 +16,13 @@ class GameScene extends egret.Sprite {
bg.graphics.drawRect(0,0,1334, 750) bg.graphics.drawRect(0,0,1334, 750)
bg.graphics.endFill() bg.graphics.endFill()
this.addChild(bg) this.addChild(bg)
// if (!Store.isCatcher()) {
this.controller = new Controller(Store.isCatcher())
this.addChild(this.controller)
// }
this.map = new Map() this.map = new Map()
this.map.y = 15 this.map.y = 15
this.map.x = 10 this.map.x = 10
this.addChild(this.map) this.addChild(this.map)
this.controller = new Controller(Store.isCatcher())
this.addChild(this.controller)
} }
public release() { public release() {
......
...@@ -61,7 +61,7 @@ class RoomScene extends egret.Sprite { ...@@ -61,7 +61,7 @@ class RoomScene extends egret.Sprite {
if(this.avatars && this.avatars.parent){ if(this.avatars && this.avatars.parent){
this.avatars.parent.removeChild(this.avatars) this.avatars.parent.removeChild(this.avatars)
} }
this.avatars = new AvatarGroup(members) this.avatars = new AvatarGroup(members, true)
this.avatars.y = 330 this.avatars.y = 330
this.avatars.x = 667 - (members.length * 100) / 2 this.avatars.x = 667 - (members.length * 100) / 2
this.addChild(this.avatars) this.addChild(this.avatars)
......
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