common-game
Advanced tools
Comparing version 0.0.8 to 0.0.9
{ | ||
"name": "common-game", | ||
"version": "0.0.8", | ||
"version": "0.0.9", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "common-game.js", |
@@ -28,2 +28,38 @@ import * as PIXI from "@tbminiapp/pixi-miniprogram-engine"; | ||
} | ||
fullClick(callback) { | ||
this.destroyContainer("fullClick"); | ||
let clickContainer = this.getContainer("fullClick"); | ||
// 绘制个矩形,解决触摸事件 | ||
let rect1 = new PIXI.Graphics(); | ||
rect1.beginFill(0xff0000, 0); | ||
rect1.drawRect(0, 0, this.namespace.width, this.namespace.height); | ||
rect1.endFill(); | ||
clickContainer.addChild(rect1); | ||
clickContainer.setChildIndex(rect1, 0); | ||
clickContainer.interactive = true; | ||
let startPoint;// = { x, y, baseX: this.playerSprite.x, baseY: this.playerSprite.y }; | ||
// 绑定事件 | ||
clickContainer.on('touchstart', (e) => { | ||
let x = e.data.global.x, y = e.data.global.y; | ||
startPoint = { x, y }; | ||
if (callback) { callback("start", e); } | ||
}) | ||
.on('touchmove', (e) => { | ||
let x = e.data.global.x, y = e.data.global.y; | ||
let moveX = x - startPoint.x; | ||
let moveY = y - startPoint.y; | ||
e.moveV = { x: moveX, y: moveY }; | ||
if (callback) { callback("move", e); } | ||
}) | ||
.on('touchend', (e) => { | ||
startPoint = null; | ||
if (callback) { callback("end", e); } | ||
}) | ||
.on('touchendoutside', (e) => { | ||
startPoint = null; | ||
if (callback) { callback("end", e); } | ||
}); | ||
} | ||
parseData(options) { | ||
@@ -30,0 +66,0 @@ try { |
41418
1165