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 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.