Search code examples
javascriptcollision-detectioncreatejs

Createjs collision issue localToLocal not a function error


Im trying to check collision between My (Loc) and CandyLocation. Im getting this error Uncaught TypeError: loc.localToLocal is not a function.

Any idea what I'm doing wrong or how i can fix it?

  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;
        }

Solution

  • Are you sure loc is a DisplayObject?