mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-09-29 09:22:18 -07:00
Defer animation start so arrows don't start halfway materialized
Took 13 minutes
This commit is contained in:
parent
ccbdcc5f74
commit
52b769a98e
2 changed files with 12 additions and 1 deletions
|
|
@ -178,7 +178,12 @@ void ArrowItem::startDrawAnimation()
|
|||
|
||||
strokeDurationMs = qBound(kMinStrokeDurationMs, centerLine.length() * kMsPerPixel, kMaxStrokeDurationMs);
|
||||
glowFadeDurationMs = kGlowFadeDurationMs;
|
||||
animationClock.start();
|
||||
// The clock is started on the first animationEvent() tick so that t=0
|
||||
// corresponds to the first rendered frame. Starting it here would count
|
||||
// the time spent before the item's first paint (event-loop delays, bursts
|
||||
// of arrows created together), making the arrow appear already partway
|
||||
// drawn when it first shows up.
|
||||
animationStarted = false;
|
||||
drawProgress = 0.0;
|
||||
glowAlpha = 1.0;
|
||||
update();
|
||||
|
|
@ -189,6 +194,11 @@ void ArrowItem::startDrawAnimation()
|
|||
|
||||
bool ArrowItem::animationEvent()
|
||||
{
|
||||
if (!animationStarted) {
|
||||
animationClock.start();
|
||||
animationStarted = true;
|
||||
}
|
||||
|
||||
const qint64 elapsed = animationClock.elapsed();
|
||||
if (elapsed >= strokeDurationMs + glowFadeDurationMs) {
|
||||
drawProgress = 1.0;
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@ private:
|
|||
qreal glowFadeDurationMs = 0;
|
||||
qreal drawProgress = 1.0;
|
||||
qreal glowAlpha = 0.0;
|
||||
bool animationStarted = false;
|
||||
|
||||
static constexpr qreal glowExtent = 12.0;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue