Commit ee5f3c96 by Shawn Wang

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

parents 9dc2f907 8e0554a7
const gridWidth = 72
const gridHeight = 72
const gridsInX = 14
const gridsInY = 10
class Map extends egret.Sprite {
private grids:any = []
public constructor() {
super();
this.init()
}
// 初始化(给开始按钮绑定点击事件)
private init() {
console.log('Map.init')
for (let i = 0; i < gridsInY; i++) {
this.grids.push([])
for (let j = 0; j < gridsInX; j++) {
const grid = new MapGrid()
grid.x = j * gridWidth
grid.y = i * gridHeight
this.grids[i].push(grid)
this.addChild(grid)
}
}
if (Store.isCatcher()) {
const mask = new egret.Shape()
mask.x = 100
mask.y = 100
mask.graphics.lineStyle( 10, 0x00ff00 );
mask.graphics.beginFill( 0xff0000, 1);
mask.graphics.drawCircle( 0, 0, 50 );
mask.graphics.endFill();
mask.touchEnabled = false
this.mask = mask
}
// put display object to this scene
}
public release() {
// 移除事件
}
}
\ No newline at end of file
class MapGrid extends egret.Sprite {
private bg:egret.Bitmap = new egret.Bitmap()
public constructor() {
super();
this.init()
}
// 初始化(给开始按钮绑定点击事件)
private init() {
console.log('Map.init')
this.bg.texture = RES.getRes('grid_jpg')
this.addChild(this.bg)
this.bg.touchEnabled = true
this.bg.addEventListener(egret.TouchEvent.TOUCH_BEGIN, this.onTouchTap, this)
}
private onTouchTap() {
console.log(this, this.parent)
if (Store.isCatcher()) {
console.log(this, this.parent)
// const map = SceneManager.getInstance().gameScene.map
}
}
public release() {
// 移除事件
}
}
\ No newline at end of file
const _state = {}
let _state = {
role: null,
cid: null,
roomId: null,
}
class Store {
static getState() {
return _state
}
static onMessage(message) {
const { payload } = message
switch (message.type) {
case 'start':
case 'game_ready':
const { cid, room_id, payload: { role } } = payload
_state = {
..._state,
cid,
role,
roomId: room_id,
}
break;
default:
......@@ -16,4 +25,9 @@ class Store {
}
return _state
}
static isCatcher() {
return true
return _state.role === 'ghost'
}
}
\ No newline at end of file
class GameScene extends egret.Sprite {
private controller: egret.Sprite
public map
public constructor() {
super();
this.init()
......@@ -15,7 +15,8 @@ class GameScene extends egret.Sprite {
this.controller = new Controller()
this.addChild(this.controller)
this.controller.addEventListener("position_change", this.onPositionChange, this)
this.map = new Map()
this.addChild(this.map)
this.addChild(this.me)
}
......
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