Russian Qt Forum

Qt => Qt Quick => Тема начата: Ice_Bear от Июнь 17, 2013, 13:03



Название: анимация feat цикл
Отправлено: Ice_Bear от Июнь 17, 2013, 13:03
здравствуйте,

ниже привожу кусок кода, который листает картинки (аналогично слайд-шоу), расположенные по кругу.Число картинок 6 штук.  Код написан тупо в лоб. Фрагменты, соответствующие каждому из 6 состояний цикла разделены пустой строкой.

Код:
		
SequentialAnimation {
running: true
loops: Animation.Infinite

NumberAnimation {
target: main_camera; property: "index_z"
from: 25; to: 15
easing.type: Easing.OutExpo
duration: 1000
}
PauseAnimation { duration: 1000 }
NumberAnimation {
target: main_camera; property: "index_z"
from: 15; to: 25
easing.type: Easing.OutExpo
duration: 1000
}
PauseAnimation { duration: 3000 }

NumberAnimation {
target: main_camera; property: "index_1"
from: 0; to: 1
easing.type: Easing.OutExpo
duration: 3000
}
PauseAnimation { duration: 300 }
NumberAnimation {
target: main_camera; property: "index_z"
from: 25; to: 15
easing.type: Easing.OutExpo
duration: 1000
}
PauseAnimation { duration: 1000 }
NumberAnimation {
target: main_camera; property: "index_z"
from: 15; to: 25
easing.type: Easing.OutExpo
duration: 1000
}
PauseAnimation { duration: 3000 }

NumberAnimation {
target: main_camera; property: "index_1"
from: 1; to: 2
easing.type: Easing.OutExpo
duration: 3000
}
PauseAnimation { duration: 300 }
NumberAnimation {
target: main_camera; property: "index_z"
from: 25; to: 15
easing.type: Easing.OutExpo
duration: 1000
}
PauseAnimation { duration: 1000 }
NumberAnimation {
target: main_camera; property: "index_z"
from: 15; to: 25
easing.type: Easing.OutExpo
duration: 1000
}
PauseAnimation { duration: 3000 }

NumberAnimation {
target: main_camera; property: "index_1"
from: 2; to: 3
easing.type: Easing.OutExpo
duration: 3000
}
PauseAnimation { duration: 300 }
NumberAnimation {
target: main_camera; property: "index_z"
from: 25; to: 15
easing.type: Easing.OutExpo
duration: 1000
}
PauseAnimation { duration: 1000 }
NumberAnimation {
target: main_camera; property: "index_z"
from: 15; to: 25
easing.type: Easing.OutExpo
duration: 1000
}
PauseAnimation { duration: 3000 }

NumberAnimation {
target: main_camera; property: "index_1"
from: 3; to: 4
easing.type: Easing.OutExpo
duration: 3000
}
PauseAnimation { duration: 300 }
NumberAnimation {
target: main_camera; property: "index_z"
from: 25; to: 15
easing.type: Easing.OutExpo
duration: 1000
}
PauseAnimation { duration: 1000 }
NumberAnimation {
target: main_camera; property: "index_z"
from: 15; to: 25
easing.type: Easing.OutExpo
duration: 1000
}
PauseAnimation { duration: 3000 }

NumberAnimation {
target: main_camera; property: "index_1"
from: 4; to: 5
easing.type: Easing.OutExpo
duration: 3000
}
PauseAnimation { duration: 300 }
NumberAnimation {
target: main_camera; property: "index_z"
from: 25; to: 15
easing.type: Easing.OutExpo
duration: 1000
}
PauseAnimation { duration: 1000 }
NumberAnimation {
target: main_camera; property: "index_z"
from: 15; to: 25
easing.type: Easing.OutExpo
duration: 1000
}
PauseAnimation { duration: 3000 }

NumberAnimation {
target: main_camera; property: "index_1"
from: 5; to: 6
easing.type: Easing.OutExpo
duration: 3000
}
PauseAnimation { duration: 300 }
NumberAnimation {
target: main_camera; property: "index_z"
from: 25; to: 15
easing.type: Easing.OutExpo
duration: 1000
}
PauseAnimation { duration: 1000 }
NumberAnimation {
target: main_camera; property: "index_z"
from: 15; to: 25
easing.type: Easing.OutExpo
duration: 1000
}
PauseAnimation { duration: 3000 }
}


В каждом фрагменте меняются только две переменные: from: 0; to:1 (from: 1; to:2 и т.д. до 6):

Код:
NumberAnimation {
target: main_camera; property: "index_1"
from: 1; to: 2
easing.type: Easing.OutExpo
duration: 3000
}


скажите пожалуйста, можно ли это реализовать в цикле, не дублируя код?

спасибо


Название: Re: анимация feat цикл
Отправлено: OKTA от Июнь 17, 2013, 23:36
А чем PathView не устроила?


Название: Re: анимация feat цикл
Отправлено: Ice_Bear от Июнь 18, 2013, 07:47
я про нее не смотрел, сейчас гляну, спасибо