Commit 9dc2f907 by Shawn Wang

delta refactor

parent 7196a511
...@@ -21,4 +21,22 @@ class Guy extends egret.Sprite { ...@@ -21,4 +21,22 @@ class Guy extends egret.Sprite {
texture._setBitmapData(this.imageLoader.data) texture._setBitmapData(this.imageLoader.data)
this.avatar.texture = texture this.avatar.texture = texture
} }
private step = 72
public applyDelta(delta){
this.x += this.step * delta.x
this.y += this.step * delta.y
if(this.x <= 0){
this.x = 0
}
if(this.y <= 0){
this.y = 0
}
if(this.y >= 72*9){
this.y = 72*9
}
if(this.x >= 72*13){
this.x = 72*13
}
}
} }
\ No newline at end of file
...@@ -19,10 +19,9 @@ class GameScene extends egret.Sprite { ...@@ -19,10 +19,9 @@ class GameScene extends egret.Sprite {
this.addChild(this.me) this.addChild(this.me)
} }
private step = 72
private onPositionChange(delta){ private onPositionChange(delta){
this.me.x += this.step * delta.data.x this.me.applyDelta(delta.data)
this.me.y += this.step * delta.data.y
} }
public release() { public release() {
......
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