拼图的 KineticJS 旋转问题

KineticJS rotation issue for puzzle pieces

本文关键字:问题 旋转 KineticJS 拼图      更新时间:2023-09-26

目前我有 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();
            }); 

这是我的 JSfiddle : http://jsfiddle.net/e70n2693/39/

我认为

你的偏移量可能是错误的,当我把它变成一个具有x和y属性的对象而不是数组(小提琴)时,它就有效了:

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