Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Reference Error: mapToItem is not defined



  • This is the code:

    var pnt = mapToItem(player, food.x, food.y);
    

    I'm getting Reference Error: mapToItem is not defined.
    I guess I have to include something, but I'm not sure what and where?


  • Moderators

    mapToItem() is a function of Item component - so you need to specify an object. Example:

    Rectangle {
      id: foo
    }
    
    function getPoint() {
      let pnt = foo.mapToItem(player, food.x, food.y)
      return pnt
    }
    

  • Moderators

    mapToItem() is a function of Item component - so you need to specify an object. Example:

    Rectangle {
      id: foo
    }
    
    function getPoint() {
      let pnt = foo.mapToItem(player, food.x, food.y)
      return pnt
    }
    

Log in to reply