我正在尝试检查My(Loc)和CandyLocation之间的冲突。我收到此错误Uncaught TypeError:loc.localToLocal不是函数。

知道我在做什么错或如何解决吗?

  var loc;
        function checkIfeatingFood() {
            loc = locations[locations.length - 1];
            // for (var j = 0; j < candyLocations.length; j++) {
            for (var j = 0; j < answersContainer.children.length; j++) {

                var candyLocation = answersContainer.children[j];
                candyLocation.alpha = .2;
                var pt = loc.localToLocal(100, 0, candyLocation);
                console.log(candyLocation.x, candyLocation.y); // the position local to objB


                if (candyLocation.hitTest(pt.x, pt.y)) { candyLocation.alpha = 1; }


            }

            //return false;
        }

最佳答案

您确定loc是DisplayObject吗?

09-25 15:48