Quantcast
Channel: Qt DevNet forums: Qt Quick 1283365070**
Viewing all articles
Browse latest Browse all 4972

QmL Random Scale Animation

$
0
0
i’m trying to create a way to make an image change randomly its scale. i need both the function that provides the random scale and the animation between the scales to be working. But it only does it the first time, any ideas why? if you know a easy way to do it i will appreciate that import QtQuick 2.2 import QtQuick.Window 2.0 import QtQuick.Controls 1.1   Rectangle {     id: container;     width: 700     height: 700       function randomscales()     {         var scalesArray = [1, 1,1, 1.1, 0.9, 1.2, 0.8,0.7]         var randomNumber;         var actualStateNumber         do{             randomNumber = Math.floor(Math.random()*scalesArray.length);         }         while (randomNumber == actualStateNumber);         actualStateNumber = randomNumber;         return scalesArray[randomNumber];     }       Timer{         id: count1         interval: 500         running: true         repeat: true         onTriggered: {             scaleAnimation.start()             randomscales.start()         }     }       Image {         id: flor;         source: "flor.png";         x: 100         y: 100         scale: 1           transform: Scale {             id: scaleTransform             property real scale: 1             xScale: scale             yScale: scale             origin.x: 96             origin.y: 104         }           SequentialAnimation {             id: scaleAnimation             loops: 1             PropertyAnimation {                 target: scaleTransform                 properties: "scale"                 to: randomscales()                 duration: 500             }         }     } }

Viewing all articles
Browse latest Browse all 4972

Trending Articles