Learn what Felgo offers to help your business succeed. Start your free evaluation today! Felgo for Your Business

Forums

OverviewFelgo 1 Support › Problem with Entity signal

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #6291

    Fahmy

    Hi,

    I’m developing game like ant smasher. In my ‘SceneGame.qml’, I’ll create multiple entities from ‘Snail.qml’ using entityManager.createEntityFromUrl(Qt.resolvedUrl(“entities/Snail.qml”)).

    Snail.qml will emit smashed() signal when it get clicked. But how to connect the signal from Snail to SceneGame?

    === SceneGame.qml ===

        function createEntities()
        {
            entityManager.createEntityFromUrl(Qt.resolvedUrl("entities/Snail.qml"));
            entityManager.createEntityFromUrl(Qt.resolvedUrl("entities/Snail.qml"));
        }

     

    === Snail.qml ===

        MouseArea
        {
            anchors.fill: colliderCiput
            onClicked:
            {
                pathMovement.stop()
                soundSplat.play()
                timerSplat.start()
                spriteSnail.opacity = 0
                imgSplat.opacity = 1
                smashed() // Signal
            }
        }

     

    #6295

    Christian
    Felgo Team

    Hi Fahmy,

    good question!

    You can do the following:

    Emit the signal in your GameWindow and emit it from there, like in the following example code:

    // --- main.qml --- //
    GameWindow {
     id: gameWindow
    
     signal snailSmashed
     
     Scene {
      id: gameScene
     }
    }
    
    // --- Snail.qml --- //
    gameWindow.snailSmashed()

    Cheers, Chris

     

    #6299

    Fahmy

    Thanks a lot Christian! It works! 🙂

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

RSS feed for this thread

You must be logged in to reply to this topic.

Qt_Technology_Partner_RGB_475 Qt_Service_Partner_RGB_475_padded