【发布时间】:2015-02-15 08:38:16
【问题描述】:
我试图让我的板在单击按钮时闪烁绿色。
我添加了以下颜色动画代码来帮助创建闪烁效果,以便电路板可以从其原始颜色变为绿色,然后返回其原始颜色。
我在一些代码示例中看到ColorAnimation 也可以像ColorAnimation on color{...} 这样使用。我尝试使用它来引用 rectangle 颜色属性,但它抱怨 color 是一个无效属性,这就是为什么我在下面的代码中没有它。
SequentialAnimation
{
running: true
loops: Animation.Infinite
ColorAnimation
{
to: "green"
duration: 500
}
ColorAnimation
{
to: "transparent"
duration: 500
}
}
上面的代码片段已经进入下面的转发器代码。下面的代码处理以我开始使用的黑白颜色显示我的电路板。
Repeater
{
id: board
model: 64
Rectangle
{
color: getWhiteOrBlack(index)
opacity: 0.45
width: getSquareSize()
height: getSquareSize()
x: getX(index)
y: getY(index)
MouseArea
{
anchors.fill: parent
onClicked:
{
pawn.x = parent.x
pawn.y = parent.y
if (starting_position == false)
{
starting.x = parent.x
starting.y = parent.y
starting_position = true
starting_index = index
ending.visible = false
}
else
{
ending.visible = true
ending.x = parent.x
ending.y = parent.y
ending_index = index
Board.move(getRow(starting_index), getColumn(starting_index), getRow(ending_index), getColumn(ending_index))
starting_position = false
}
}
}
SequentialAnimation
{
running: true
loops: Animation.Infinite
ColorAnimation
{
to: "green"
duration: 500
}
ColorAnimation
{
to: "transparent"
duration: 500
}
}
}
}
但是,每当我单击应该触发绿色闪烁的按钮时,它都不会闪烁。
我不知道如何在单击按钮时使闪烁工作,非常感谢有关如何完成此操作的任何帮助,谢谢。
【问题讨论】:
-
好问题。有兴趣看看是否有人有任何解决方案。