Forums

OverviewV-Play 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
    V-Play 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.

Voted #1 for:

  • Easiest to learn
  • Most time saving
  • Best support

Develop Cross-Platform Apps and Games 50% Faster!

  • Voted the best supported, most time-saving and easiest to learn cross-platform development tool
  • Based on the Qt framework, with native performance and appearance on all platforms including iOS and Android
  • Offers a variety of plugins to monetize, analyze and engage users
FREE!
create apps
create games
cross platform
native performance
3rd party services
game network
multiplayer
level editor
easiest to learn
biggest time saving
best support