OverviewV-Play 1 Supportevent associated with entering a scene › Reply To: event associated with entering a scene

OverviewV-Play 1 Supportevent associated with entering a scene › Reply To: event associated with entering a scene


Hi Chris

I am facing a minor misunderstanding with function call timing, and want to ask about when the following script: is called, i.e. (placed here for convenience)

            StateChangeScript {
                script: {

in relation to when other scripts in the objects within the actual game scene are called.

To try to explain my situation, I call a function gameScene.resetGame() above which initiates a bunch of game setups. Within resetGame() it calls a function in an external Javascipt (associated with that GameScene QML only) that initialises an array with character data I use later. Like so:

function resetGame() {
        // randomise the letters for buttons based on level no

Then in the GameScene I have some simplebutton with text that are assigned using an external JS function that pulls the character data I previously setup. Like so:

SimpleButton { id: btnLetter1; width: 50; height: 50; color: "#C9A582"; text: LetterLogic.getLetter(0); onClicked: postpendLetter(text) }

The problem is the char text for those simple buttons are coming up empty, even though I can see the data is being initialised, and that getter function is working.

The solution I have so far is taking out the text: assignment above, and putting it in the resetGame(), like so:

    function resetGame() {
        btnLetter1.text = LetterLogic.getLetter(0)

This works fine now, but I wonder why it’s not possible to do text: LetterLogic.getLetter(0) method which seems more intuitive? Maybe it’s a code process/order issue that I don’t see right now.

Cheers, Michael.

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
create apps
create games
cross platform
native performance
3rd party services
game network
level editor
easiest to learn
biggest time saving
best support