Commit 354e8916 by Shawn Wang

control 666

parent 1caae731
......@@ -33,24 +33,28 @@ class Controller extends egret.Sprite {
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.down.graphics.beginFill(0xFF00FF, 1)
this.down.graphics.drawRect(93, 186, 80, 80)
this.down.graphics.endFill()
this.down.touchEnabled = true
this.down.alpha = 0
this.down.addEventListener(egret.TouchEvent.TOUCH_BEGIN, this.controlTouchBegin, this)
this.left.graphics.beginFill(0xFF00FF, 1)
this.left.graphics.drawRect(0, 93, 80, 80)
this.left.graphics.endFill()
this.left.touchEnabled = true
this.left.alpha = 0
this.left.addEventListener(egret.TouchEvent.TOUCH_BEGIN, this.controlTouchBegin, this)
this.right.graphics.beginFill(0xFF00FF, 1)
this.right.graphics.drawRect(186, 93, 80, 80)
this.right.graphics.endFill()
this.right.touchEnabled = true
this.right.alpha = 0
this.right.addEventListener(egret.TouchEvent.TOUCH_BEGIN, this.controlTouchBegin, this)
controlContainer.addChild(this.up)
......
......@@ -29,11 +29,11 @@ class Guy extends egret.Sprite {
if(this.x <= 0){
this.x = 0
}
if(this.y <= 0){
this.y = 0
if(this.y <= 15){
this.y = 15
}
if(this.y >= 72*9){
this.y = 72*9
if(this.y >= 72*9 + 15){
this.y = 72*9 + 15
}
if(this.x >= 72*13){
this.x = 72*13
......
......@@ -12,15 +12,23 @@ class GameScene extends egret.Sprite {
// 初始化(给开始按钮绑定点击事件)
private init() {
// put display object to this scene
let bg = new egret.Shape()
bg.graphics.beginFill(0x343e5f, 1)
bg.graphics.drawRect(0,0,1334, 750)
bg.graphics.endFill()
this.addChild(bg)
this.controller = new Controller()
this.addChild(this.controller)
this.controller.addEventListener("position_change", this.onPositionChange, this)
this.map = new Map()
this.map.y = 15
this.me.y = 15
this.addChild(this.map)
this.addChild(this.me)
}
private onPositionChange(delta){
this.me.applyDelta(delta.data)
}
......
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