Commit 1c0c374e by Shawn Wang

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

parents 6381a215 613892d1
...@@ -96,27 +96,31 @@ class Map extends egret.Sprite { ...@@ -96,27 +96,31 @@ class Map extends egret.Sprite {
centerGrid.bg.texture = RES.getRes('grid_select_jpg') centerGrid.bg.texture = RES.getRes('grid_select_jpg')
const runners = Store.getState().runners const runners = Store.getState().runners
this.touchArea.alpha = 1 // this.touchArea.alpha = 1
this.touchArea.x = x - 2 * gridWidth this.touchArea.x = x - 2 * gridWidth
this.touchArea.y = y - 2 * gridHeight this.touchArea.y = y - 2 * gridHeight
surroundedGrids.forEach(grid => { // surroundedGrids.forEach(grid => {
grid.alpha = 1 // grid.alpha = 1
})
// const twTouchArea = egret.Tween.get( this.touchArea );
// twTouchArea.to( {alpha: 1}, 300 ).call(function() {
// }) // })
const twTouchArea = egret.Tween.get( this.touchArea );
twTouchArea.to( {alpha: 1}, 300 ).call(function() {
surroundedGrids.forEach(grid => {
grid.alpha = 1
})
// egret.Tween.get(grid).to({ alpha: 1 }, 300)
})
// surroundedGrids.forEach(grid => { // surroundedGrids.forEach(grid => {
// egret.Tween.get(grid).to({ alpha: 1 }, 300) // egret.Tween.get(grid).to({ alpha: 1 }, 300)
// }) // })
runners.forEach(runner => { runners.forEach(runner => {
console.log(runner.x, runner.y, this.touchArea.hitTestPoint(runner.x * gridWidth, runner.y * gridHeight)) console.log(runner.x, runner.y, this.touchArea.hitTestPoint(runner.x * gridWidth, runner.y * gridHeight))
const runnerInMap = this.runnerMap[runner.t_cid] const runnerInMap = this.runnerMap[runner.t_cid]
if (this.touchArea.hitTestPoint(runnerInMap.x * gridWidth, runnerInMap.y * gridHeight)) { if (this.touchArea.hitTestPoint(runnerInMap.x, runnerInMap.y)) {
runnerInMap.alpha = 1 runnerInMap.alpha = 1
} }
}) })
this.getCatchedRunners(x, y).forEach(runner => { this.getCatchedRunners(x, y).forEach(runner => {
platform.sendSocketMessage({ platform.sendSocketMessage({
data: JSON.stringify({ data: JSON.stringify({
type: 'catch', type: 'catch',
...@@ -133,6 +137,10 @@ class Map extends egret.Sprite { ...@@ -133,6 +137,10 @@ class Map extends egret.Sprite {
if (Store.isMe(runner.t_cid) || Store.isCatcher()) { if (Store.isMe(runner.t_cid) || Store.isCatcher()) {
SoundManager.getInstance().playCatched() SoundManager.getInstance().playCatched()
} }
if (Store.isCatcher()) {
this.runnerMap[runner.t_cid].alpha = 0
}
}) })
setTimeout(() => { setTimeout(() => {
centerGrid.bg.texture = RES.getRes('grid_jpg') centerGrid.bg.texture = RES.getRes('grid_jpg')
......
class Rank extends egret.Sprite {
public constructor(userData) {
super()
this.init(userData)
}
private avatar = new egret.Bitmap()
private bg = new egret.Bitmap()
private imageLoader = new egret.ImageLoader()
private init(userData) {
this.bg.width = 100
this.bg.height = 100
this.bg.texture = RES.getRes("avatar_bg_jpg")
this.addChild(this.bg)
this.avatar.x = 10
this.avatar.y = 10
this.avatar.width = 80
this.avatar.height = 80
this.imageLoader.addEventListener(egret.Event.COMPLETE,this.loadCompleteHandler,this)
this.imageLoader.load(userData.avatar_url || "http://www.insajderi.com/wp-content/uploads/2018/01/asdja.jpg")
this.addChild(this.avatar)
}
private loadCompleteHandler() {
let texture = new egret.Texture()
texture._setBitmapData(this.imageLoader.data)
this.avatar.texture = texture
}
}
class RankGroup extends egret.Sprite {
public constructor(ranks) {
super()
this.init(ranks)
}
private init(ranks) {
ranks.forEach((rank, index) => {
let yPosition = index * 100
let avatar = new Avatar(rank[0])
avatar.y = yPosition
this.addChild(avatar)
let name = new egret.TextField()
name.text = rank[0].nick_name
name.y = yPosition + 40
name.x = 120
this.addChild(name)
let score = new egret.TextField()
score.text = rank[1]
score.y = yPosition + 40
score.x = 500
this.addChild(score)
})
}
}
\ No newline at end of file
class GameoverScene extends egret.Sprite { class GameoverScene extends egret.Sprite {
private startLabel: egret.TextField private startLabel: egret.TextField
private players: Array<any> private rankGroup: any
private avatars: any
public constructor() { public constructor() {
super(); super();
...@@ -15,19 +15,33 @@ class GameoverScene extends egret.Sprite { ...@@ -15,19 +15,33 @@ class GameoverScene extends egret.Sprite {
this.initBg() this.initBg()
this.initEndLabel() this.initEndLabel()
this.initBackLabel() this.initBackLabel()
// this.initRankGroup()
} }
public update(data) { public update(data) {
const payload = data.payload const payload = data.payload
switch (data.type) { switch (data.type) {
case 'game_end': case 'game_end':
this.updateRank(payload)
default: default:
break; break;
} }
} }
private updateRank(data) {
if (this.rankGroup && this.rankGroup.parent) {
this.rankGroup.parent.removeChild(this.rankGroup)
}
this.rankGroup = new RankGroup(data.rank)
this.rankGroup.x = 400
this.rankGroup.y = 250
this.addChild(this.rankGroup)
}
// private initRankGroup() {
// this.rankGroup
// }
private initBackLabel() { private initBackLabel() {
var backLabel = new egret.TextField() var backLabel = new egret.TextField()
backLabel.text = '< 返回' backLabel.text = '< 返回'
...@@ -61,18 +75,18 @@ class GameoverScene extends egret.Sprite { ...@@ -61,18 +75,18 @@ class GameoverScene extends egret.Sprite {
}) })
SceneManager.getInstance().changeScene('roomScene') SceneManager.getInstance().changeScene('roomScene')
} }
private initCountDown(res) { // private initCountDown(res) {
var cdText = new egret.TextField() // var cdText = new egret.TextField()
cdText.text = '10' // cdText.text = '10'
const timer = setInterval(() => { // const timer = setInterval(() => {
if (cdText.text == '0') { // if (cdText.text == '0') {
clearInterval(timer) // clearInterval(timer)
SceneManager.getInstance().changeScene('roomScene') // SceneManager.getInstance().changeScene('roomScene')
return // return
} // }
cdText.text = `${Number(cdText.text) - 1}` // cdText.text = `${Number(cdText.text) - 1}`
}, 1000) // }, 1000)
} // }
private initBg() { private initBg() {
var shape: egret.Shape = new egret.Shape(); var shape: egret.Shape = new egret.Shape();
......
...@@ -49,10 +49,12 @@ class RoomScene extends egret.Sprite { ...@@ -49,10 +49,12 @@ class RoomScene extends egret.Sprite {
private updateStartLabelAndPlayers(payload) { private updateStartLabelAndPlayers(payload) {
const {seat, members, nick_name} = payload const {seat, members, nick_name} = payload
if (payload.seat == 0) { if (payload.seat == 0) {
this.startLabel.size = egret.TextField.default_size
this.startLabel.text = '开始' this.startLabel.text = '开始'
this.startLabel.touchEnabled = true this.startLabel.touchEnabled = true
this.startLabel.addEventListener(egret.TouchEvent.TOUCH_TAP, this.startHandler, this) this.startLabel.addEventListener(egret.TouchEvent.TOUCH_TAP, this.startHandler, this)
} else { } else {
this.startLabel.size = egret.TextField.default_size
this.startLabel.text = '等待房主点击开始' this.startLabel.text = '等待房主点击开始'
this.startLabel.touchEnabled = false this.startLabel.touchEnabled = false
} }
......
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