Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/38.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 拼图块的KineticJS旋转问题_Javascript_Rotation_Kineticjs_Puzzle_Hammer.js - Fatal编程技术网

Javascript 拼图块的KineticJS旋转问题

Javascript 拼图块的KineticJS旋转问题,javascript,rotation,kineticjs,puzzle,hammer.js,Javascript,Rotation,Kineticjs,Puzzle,Hammer.js,目前我有KineticJS v5.1和hammerJS绑定用于我的多点触控,我正在为我的项目做一个益智游戏,现在我的益智块只能在我的益智块边缘旋转,当我做2个手指旋转时,我怎样才能旋转我的拼图,使旋转在拼图的中间,而不是拼图的边缘? var hammertime = Hammer(piecesArray[i][j].shape); hammertime.on("transformstart", function(e) { t

目前我有KineticJS v5.1和hammerJS绑定用于我的多点触控,我正在为我的项目做一个益智游戏,现在我的益智块只能在我的益智块边缘旋转,当我做2个手指旋转时,我怎样才能旋转我的拼图,使旋转在拼图的中间,而不是拼图的边缘?

        var hammertime = Hammer(piecesArray[i][j].shape);
            hammertime.on("transformstart", function(e) {
                this.startRatation = this.rotation();
            }).on("transform", function(e) {
                this.rotation((this.startRatation || 0) + e.gesture.rotation);
                this.getLayer().draw();
            }); 

这是我的JSFIDLE:

我认为您的偏移量可能是错误的,当我将其设置为具有x和y属性的对象而不是数组()时,它会起作用:

offset: { x: pieceWidth / 2, y: pieceHeight / 2 },