微信小程序(游戏)----拖拽拼图(拖拽和切换功能的实现)
效果图
touchstart
- 获取当前触摸位置的坐标(x,y);
- 记录触摸点下view的各项坐标值;
- 记录触摸点下view的起点坐标,背景坐标,以及触摸点的坐标;
- 设置拖拽view为显示状态、设置起始坐标以及背景坐标为记录对应个坐标。
page.onTouchStart = function(e){
let x = parseInt(e.touches[0].pageX / _this.width), y = parseInt(e.touches[0].pageY / _this.height);
let val = _this.newTypeArr[y][x];
_this.cval = _this.newTypeArr[y][x];
_this.page.setData({
status: true,
currentX: val.x * _this.widt