Find the Best Demos and Examples

Check out this quick tour to find the best demos and examples for you, and to see how the Felgo SDK can help you to develop your next app or game!

Forums

OverviewFelgo 2 Support (Qt 5) › JavaScript debugging in Qt Creator

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #13741

    Vi

    I’m following this tut Match-3 . And I’m trying to rewrite function handleClick (in GameArea.qml)  as my algorithm:

    function handleClick(row, column, type) {
            //        // copy current field, allows us to change the array without modifying the real game field
            //        // this simplifies the algorithms to search for connected blocks and their removal
            //        var fieldCopy = field.slice()
    
            //        // count and delete connected blocks
            //        var blockCount = getNumberOfConnectedBlocks(fieldCopy, row, column, type)
            //        if(blockCount >= 3) {
            //            removeConnectedBlocks(fieldCopy)
            //        }
    
            burn(row, column, type, 1)
        }
    
        function burn(row, column, type, count) {
            if(count > 2) {
                var block = field[index(row, column)]
                if(block !== null) {
                    field[index(row, column)] = null
                    entityManager.removeEntityById(block.entityId)
                }
                count = burn(row + 1, column, type, count + 1)
                count = burn(row - 1, column, type, count)
                count = burn(row, column + 1, type, count)
                return burn(row, column - 1, type, count)
            }
    
            var blockNext = field[index(row + 1, column)]
            if((block !== null) && (block.type === type))
                count = burn(row + 1, column, type, count + 1)
            blockNext = field[index(row - 1, column)]
            if(block !== null && block.type === type)
                count = burn(row - 1, column, type, count + 1)
            blockNext = field[index(row, column - 1)]
            if(block !== null && block.type === type)
                count = burn(row, column - 1, type, count + 1)
            blockNext = field[index(row, column + 1)]
            if(block !== null && block.type === type)
                count = burn(row, column + 1, type, count + 1)
            if(count > 2) {
                var blockThis = field[index(row, column)]
                if(blockThis !== null) {
                    field[index(row, column)] = null
                    entityManager.removeEntityById(block.entityId)
                }
            }
            return count
        }

    I ran the app but it didn’t work. So I debug the code, I put the break point at line:

    var blockNext = field[index(row + 1, column)]
            if((block !== null) && (block.type === type))
                count = burn(row + 1, column, type, count + 1)

    then press F5 and F10 few times. The debug pointer points to above lines only. I cannot see the pointer points to followed lines. How can I debug this JavaScript code in Qt Creator?

    #13743

    Günther
    Felgo Team

    Hi Vi!

    When you run the application in debugging mode, the application execution should stop at the breakpoints.
    Once it is stopped, you should be able to navigate through the code step-by-step. You can use the buttons in the debugging area to go to the next statement or navigate into sub-functions (with the Step Over, or Step Into commands):

    http://postimg.org/image/tc9ugstn5/

     

Viewing 2 posts - 1 through 2 (of 2 total)

RSS feed for this thread

You must be logged in to reply to this topic.