Commit 7196a511 by Shawn Wang

add me

parent d3f5dd4b
class Guy extends egret.Sprite {
public constructor() {
super()
this.init()
}
private avatar = new egret.Bitmap()
private imageLoader = new egret.ImageLoader()
private init() {
this.avatar.width = 72
this.avatar.height = 72
this.imageLoader.addEventListener(egret.Event.COMPLETE,this.loadCompleteHandler,this)
this.imageLoader.load("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
}
}
\ No newline at end of file
......@@ -7,7 +7,7 @@ class GameScene extends egret.Sprite {
this.init()
}
private pointtt = new egret.Shape()
private me = new Guy()
// 初始化(给开始按钮绑定点击事件)
private init() {
......@@ -16,16 +16,13 @@ class GameScene extends egret.Sprite {
this.addChild(this.controller)
this.controller.addEventListener("position_change", this.onPositionChange, this)
this.pointtt.graphics.beginFill(0xFF0000, 1)
this.pointtt.graphics.drawCircle(667, 375, 15)
this.pointtt.graphics.endFill()
this.addChild(this.pointtt)
this.addChild(this.me)
}
private step = 72
private onPositionChange(delta){
this.pointtt.x += this.step * delta.data.x
this.pointtt.y += this.step * delta.data.y
this.me.x += this.step * delta.data.x
this.me.y += this.step * delta.data.y
}
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