Forums

OverviewV-Play 1 Support › TriggeredOnStart question

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #4349

    marta.wierszak

    Hello,

    I have a question related with on triggeredOnStart property.

    In documentation there is written that “When a timer is started, the first trigger is usually after the specified interval has elapsed.” In my program it doesn’t matter if I set it “true” or “false”, the first trigger is after the same time ( about 1 second, unfortunately it  is not after specified interval time). So I don’t know if I understand this quoted sentence properly.

    Cheers,

    Marta

    #4350

    Christian
    V-Play Team

    Hi Marta, could you please post the source code for your issue?

    Cheers, Chris

    #4352

    marta.wierszak

    Here it is:

    Image {
        id: cloudsWHITE
        x: 37
        y: -59
        width: 396
        height: 429
        source: "../../Desktop/vplayPapi/clouds.png"
        MovementAnimation {
          id: movClouds
          target: parent
          property: "pos"
          running: false
          velocity: Qt.point(0, 60)
        }
      }
      Timer {
        id: timerCloud
        running: true
        repeat: true
        onTriggered: {
          cloudsWHITE.y = -549;
          interval = 5000
          if(movClouds.running === false){
            interval = 14000;
            movClouds.start();
            movClouds.running = true
          }
          else{
            interval = 1;
            movClouds.stop();
            movClouds.running = false;
          }
        }
      }

     

    In this code I repeat the image movement from the top of the window to the bottom.

    To have fluent movement (moving background) I wanted to add the same image in the second timer that would start after (14/2=)7 seconds
    (the first image needs 14 sec to pass all window). So I set the interval = 7 s. But the timers start working at the same time.
    I don’t know if there is any esier way to create moving background, so that’s what I did.

    Hopefully it is somehow clear what I wrote 😉

    #4353

    Christian
    V-Play Team

    Hi Marta,

    yes it’s clear now :)

    For a moving background, please use the ParallaxScrollingBackground item, or see how it is done in the ChickenOutbreak demo in the file Level.qml. You should not use Timers for shifting the Images, but rather use the onYChanged signal of the Image. I am also not sure how big, i.e. how high your clouds image is, but usually you will need to make it 576×368 for the sd version, 1152×736 for hd and 2304×1472 for hd2 to support widescreen devices as well (see the guide How to create mobile games for different screen sizes and resolutions). And then you would need to make 2 images below each other, exactly like in ChickenOutbreak demo. But the easier way to do this is using the ParallaxScrollingBackground, as this item does it automatically.

    Cheers, Chris

    #4355

    marta.wierszak

    Thank you very much for your help! It works now ofc. I don’t know why I overlooked this item before going over the documentation. I’ve  also changed the size already.

    BR,

    Marta

Viewing 5 posts - 1 through 5 (of 5 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