[Qt-qml] ParallelAnimation issues

15 views
Skip to first unread message

Harri Pasanen

unread,
Jan 24, 2012, 6:21:54 AM1/24/12
to qt-...@trolltech.com
Hi,

I found out that ParallelAnimation is not truly parallel, if I try to
animate to objects
moving next to one and other, like train wagons, I get overlaps.

I'm trying to coax it into behaving by having a tiny pause, but it does not
seem to help much

ParallelAnimation {
id: pushAnimHorizontal
NumberAnimation { target: piece.ball; property: "x"; to:
piece.ball.nX; duration: 170; easing.type: Easing.InOutQuad }
SequentialAnimation { // trickery to avoid overlap
PauseAnimation { duration: 30 }
NumberAnimation { target: player; property: "x"; to: player.nX;
duration: 170; easing.type: Easing.InOutQuad }
}
}

Even with above I get the occasional overlap.

I wonder what is the minimum duration in PauseAnimation on different
platforms?
I'm testing on Meego N9 right now.

Or is there a better way?

Thanks,

Harri
_______________________________________________
Qt-qml mailing list
Qt-...@qt.nokia.com
http://lists.qt.nokia.com/mailman/listinfo/qt-qml

Timo Strömmer

unread,
Jan 24, 2012, 6:42:36 AM1/24/12
to Harri Pasanen, qt-...@trolltech.com
Hi,

Probably easiest would be to have a single animation over a variable and
then tie piece.ball.x and player.x to that.

- Timo

Harri Pasanen

unread,
Jan 25, 2012, 4:08:25 AM1/25/12
to Timo Strömmer, qt-...@trolltech.com
Hi,

Could you elaborate a bit? It is unclear to me how would I do that in
clean fashion.

Given that I have two (or more) distinct QML items, how do I tie a
single animation to those?

/Harri

Timo Strömmer

unread,
Jan 26, 2012, 4:43:17 AM1/26/12
to Harri Pasanen, qt-...@trolltech.com
Something like following could work if the distinct items cannot be bound
to the animation variable directly.


Item {
property int animvar: 0

onAnimvarChanged: {
piece.ball.x = animvar
player.x = animvar
}

NumberAnimation on animvar {
from: 0
to: player.nX
}
}

- Timo

Adriano Rezende

unread,
Feb 3, 2012, 2:12:21 PM2/3/12
to Harri Pasanen, qt-...@trolltech.com
On Tue, Jan 24, 2012 at 9:21 AM, Harri Pasanen <ha...@mpaja.com> wrote:
Hi,

I found out that ParallelAnimation is not truly parallel, if I try to
animate to objects
moving next to one and other, like train wagons, I get overlaps.

They are parallel afaik.
Can you give a self-contained testcase?

What could be happening is some kind of pixel adjustment during the animation. The x,y,width,height values are real numbers that are rounded to an int when mapping to the display, so 1-pixel shifts could happen due that fact.

Br,
Adriano

Harri Pasanen

unread,
Feb 3, 2012, 2:24:59 PM2/3/12
to Adriano Rezende, qt-...@trolltech.com
It's much more than 1-pixel, like tens of pixels.   In some cases it looks like they are serialized.
But it is not consistent, happens only maybe 1/10 times.  Looks like some display list order
is arbitrary.

I'll see if I can get together a test case when I have time.

Btw. I've seen a similar temporal oddity with following type of code:

Piece {
    id: piece
    ...

    states: State {
        name: "moved";
        PropertyChanges { target: piece; x: nX; y: nY; restoreEntryValues: false }
    }
}

The if in javascript if I have Piece A and B and do

A.state = 'moved'
B.state = 'moved'

sometimes B moves before A.


Cheers,

Harri


Adriano Rezende

unread,
Feb 3, 2012, 4:35:09 PM2/3/12
to Harri Pasanen, qt-...@trolltech.com
On Fri, Feb 3, 2012 at 5:24 PM, Harri Pasanen <ha...@mpaja.com> wrote:
On 02/03/2012 08:12 PM, Adriano Rezende wrote:
On Tue, Jan 24, 2012 at 9:21 AM, Harri Pasanen <ha...@mpaja.com> wrote:
What could be happening is some kind of pixel adjustment during the animation. The x,y,width,height values are real numbers that are rounded to an int when mapping to the display, so 1-pixel shifts could happen due that fact.

It's much more than 1-pixel, like tens of pixels.   In some cases it looks like they are serialized.
But it is not consistent, happens only maybe 1/10 times.  Looks like some display list order
is arbitrary.

It doesn't seem to be related to ParallelAnimation. A small test case would highlight what is really happening.



Piece {
    id: piece
    ...

    states: State {
        name: "moved";
        PropertyChanges { target: piece; x: nX; y: nY; restoreEntryValues: false }
    }
}

The if in javascript if I have Piece A and B and do

A.state = 'moved'
B.state = 'moved'

sometimes B moves before A.

 
This "moved" state is error prone; you should never define a state that modifies x,y of the 'root' item, since this item could be anchored from outside leading to binding conflicts like the following:

Item {
    YourPiece {
        state: "moved"
        anchors.fill: parent
    }
}


Br,
Adriano
Reply all
Reply to author
Forward
0 new messages