Forums

OverviewV-Play 2 Support (Qt 5) › Not sure what to do with this code

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

    Jaron

    I am using the
    “How to Make a Flappy Bird Game with V-Play”
    page as a guide for creating my own type of Flappy Bird, but I am having problems with this one part:
    Game Logic
    The game will have 3 states:

    • wait: Pipes will not move, game starts after the first touch on the screen.
    • play: Actual game.
    • gameOver: Player hits a pipe or the ground and falls down to the ground. The next touch on the screen will reset the game.

    Add a custom property to the Scene in main.qml like this:

    property string gameState: "wait"
    

    We will begin with the wait state, by setting it as default value.

    Then we can use this state to control the gravity, with a property binding

    gravity.y: scene.gameState != "wait" ? -27 : 0
    

     

    Basically, I don’t understand what to do here. I think what I’m missing is the custom property part or property binding part. I have tried putting the property string gameState: “wait” in the scene of the main.qml with the gravity.y: scene.gameState != “wait” ? -27 : 0 underneath it, but I am very sure that’s not what you are not supposed to do. I am new to this coding stuff and don’t have much experience yet. I am sure there is a really easy way to do this since the game being made is fairly simple. Any help would be appreciated. Here is the link if you need it: http://v-play.net/doc/howto-flappybird-game/

    • This topic was modified 3 years, 4 months ago.
    #9379

    Alex
    V-Play Team

    Hi Steve,

    the gravity is a property of the PhysicsWorld, please search for that item in your code and then replace it with the new property binding.

    In case you are not familiar with the xxx ? yyy : zzz syntax, it means if the expression in xxx is true then do yyy, else do zzz. So in this case, the gravity will always be -27 as long as the gameState is not “wait”.

    Cheers,
    Alex

    • This reply was modified 3 years, 4 months ago by  Alex.
    • This reply was modified 3 years, 4 months ago by  Alex.
    #9461

    Jaron

    Thanks so much.

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