Commit b35a62d8 by Shawn Wang

asldjoasd

parent 48a42560
class Controller extends egret.Sprite { class Controller extends egret.Sprite {
private myPosition = {} private myPosition = {}
public constructor() { public constructor(isCatcher) {
super(); super();
this.init() this.init(isCatcher)
} }
private control = new egret.Bitmap() private control = new egret.Bitmap()
...@@ -14,54 +14,55 @@ class Controller extends egret.Sprite { ...@@ -14,54 +14,55 @@ class Controller extends egret.Sprite {
private right = new egret.Shape() private right = new egret.Shape()
// 初始化(给开始按钮绑定点击事件) // 初始化(给开始按钮绑定点击事件)
private init() { private init(isCatcher) {
this.panel.graphics.beginFill(0x353E5D, 1) this.panel.graphics.beginFill(0x00ff00, 1)
this.panel.graphics.drawRect(1008, 0, 326, 750) this.panel.graphics.drawRect(1008, 0, 326, 750)
this.panel.graphics.endFill() this.panel.graphics.endFill()
this.addChild(this.panel) this.addChild(this.panel)
let texture: egret.Texture = RES.getRes("control_jpg") if(!isCatcher){
this.control.texture = texture let texture: egret.Texture = RES.getRes("control_jpg")
this.control.texture = texture
let controlContainer = new egret.Sprite() let controlContainer = new egret.Sprite()
this.addChild(controlContainer) this.addChild(controlContainer)
controlContainer.x = 1040 controlContainer.x = 1040
controlContainer.y = 450 controlContainer.y = 450
controlContainer.addChild(this.control) controlContainer.addChild(this.control)
this.up.graphics.beginFill(0xFF00FF, 1)
this.up.graphics.drawRect(93, 0, 80, 80)
this.up.graphics.endFill()
this.up.touchEnabled = true
this.up.alpha = 0
this.up.addEventListener(egret.TouchEvent.TOUCH_BEGIN, this.controlTouchBegin, this)
this.up.graphics.beginFill(0xFF00FF, 1) this.down.graphics.beginFill(0xFF00FF, 1)
this.up.graphics.drawRect(93, 0, 80, 80) this.down.graphics.drawRect(93, 186, 80, 80)
this.up.graphics.endFill() this.down.graphics.endFill()
this.up.touchEnabled = true this.down.touchEnabled = true
this.up.alpha = 0 this.down.alpha = 0
this.up.addEventListener(egret.TouchEvent.TOUCH_BEGIN, this.controlTouchBegin, this) this.down.addEventListener(egret.TouchEvent.TOUCH_BEGIN, this.controlTouchBegin, this)
this.down.graphics.beginFill(0xFF00FF, 1) this.left.graphics.beginFill(0xFF00FF, 1)
this.down.graphics.drawRect(93, 186, 80, 80) this.left.graphics.drawRect(0, 93, 80, 80)
this.down.graphics.endFill() this.left.graphics.endFill()
this.down.touchEnabled = true this.left.touchEnabled = true
this.down.alpha = 0 this.left.alpha = 0
this.down.addEventListener(egret.TouchEvent.TOUCH_BEGIN, this.controlTouchBegin, this) this.left.addEventListener(egret.TouchEvent.TOUCH_BEGIN, this.controlTouchBegin, this)
this.left.graphics.beginFill(0xFF00FF, 1) this.right.graphics.beginFill(0xFF00FF, 1)
this.left.graphics.drawRect(0, 93, 80, 80) this.right.graphics.drawRect(186, 93, 80, 80)
this.left.graphics.endFill() this.right.graphics.endFill()
this.left.touchEnabled = true this.right.touchEnabled = true
this.left.alpha = 0 this.right.alpha = 0
this.left.addEventListener(egret.TouchEvent.TOUCH_BEGIN, this.controlTouchBegin, this) this.right.addEventListener(egret.TouchEvent.TOUCH_BEGIN, this.controlTouchBegin, this)
this.right.graphics.beginFill(0xFF00FF, 1) controlContainer.addChild(this.up)
this.right.graphics.drawRect(186, 93, 80, 80) controlContainer.addChild(this.down)
this.right.graphics.endFill() controlContainer.addChild(this.left)
this.right.touchEnabled = true controlContainer.addChild(this.right)
this.right.alpha = 0 }
this.right.addEventListener(egret.TouchEvent.TOUCH_BEGIN, this.controlTouchBegin, this)
controlContainer.addChild(this.up)
controlContainer.addChild(this.down)
controlContainer.addChild(this.left)
controlContainer.addChild(this.right)
const me = Store.getState().runners.find(runner => runner.t_cid === Store.getState().cid) const me = Store.getState().runners.find(runner => runner.t_cid === Store.getState().cid)
......
...@@ -16,11 +16,10 @@ class GameScene extends egret.Sprite { ...@@ -16,11 +16,10 @@ 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()) { // if (!Store.isCatcher()) {
this.controller = new Controller() this.controller = new Controller(Store.isCatcher())
this.addChild(this.controller) 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
......
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