lufy's legend

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 7735|回复: 0
打印 上一主题 下一主题

缩放后,事件位置不对

[复制链接]

4

主题

0

好友

52

积分

士兵

Rank: 1

楼主
发表于 2018-8-20 14:03:07 |显示全部楼层
            InteractivePNG.prototype.hitTestPoint = function (x, y) {
                var self = this;
                var point = self.getRootCoordinate();
                point.x = x - point.x;
                point.y = y - point.y;
                for (var i = 0, l = self.childList.length; i < l; i++) {
                    var child = self.childList[0];
                    if (!child.bitmapData._locked) {
                        child.bitmapData.lock();
                    }
                    var cx = point.x - child.x;
                    var cy = point.y - child.y;
                    if (cx < 0 || cx > child.bitmapData.width * child.scaleX || cy < 0 || cy > child.bitmapData.height * child.scaleY) {
                        continue;
                    }
                    var pixel = child.bitmapData.getPixel(Math.round(cx / child.scaleX), Math.round(cy / child.scaleY));
                    if (pixel && pixel[3] > 0) {
                        return true;
                    }
                }
                return false;
            };

我也发现这个问题,自己改了一下这里,初步是可以用的了
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

防止垃圾广告,请填写任意字符

Archiver|lufy's legend

GMT+8, 2024-5-4 22:06 , Processed in 0.043039 second(s), 19 queries .

Powered by Discuz! X2.5

© 2001-2012 Comsenz Inc.

回顶部