Russian Qt Forum
Ноябрь 23, 2024, 04:44 *
Добро пожаловать, Гость. Пожалуйста, войдите или зарегистрируйтесь.
Вам не пришло письмо с кодом активации?

Войти
 
  Начало   Форум  WIKI (Вики)FAQ Помощь Поиск Войти Регистрация  

Страниц: [1]   Вниз
  Печать  
Автор Тема: анимация feat цикл  (Прочитано 2531 раз)
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
}


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

спасибо
Записан
OKTA
Гость
« Ответ #1 : Июнь 17, 2013, 23:36 »

А чем PathView не устроила?
Записан
Ice_Bear
Гость
« Ответ #2 : Июнь 18, 2013, 07:47 »

я про нее не смотрел, сейчас гляну, спасибо
Записан
Страниц: [1]   Вверх
  Печать  
 
Перейти в:  


Страница сгенерирована за 0.058 секунд. Запросов: 20.