I want to render this card and the first time it's loaded, the animation start once. What I want is the default there is no animation happen. Does anyone know how to make this happen?
class Card extends AnimationComponent {
Card(width, height)
: super.sequenced(width, height, 'card.png', 5,
textureWidth: 144.0, textureHeight: 220.0, loop: false);
}
class GameScreen extends BaseGame {
GameScreen({@required this.size}) {
add(Card(0,0));
}
}
According to the source code, you'll able to use Animation
to control the frame.
For simple, just don't call update
and keep rendering, the frame index will not be updated.
void update(double dt) {
clock += dt;
elapsed += dt;
if (isSingleFrame) {
return;
}
if (!loop && isLastFrame) {
onCompleteAnimation?.call();
return;
}
while (clock > currentFrame.stepTime) {
if (!isLastFrame) {
clock -= currentFrame.stepTime;
currentIndex++;
} else if (loop) {
clock -= currentFrame.stepTime;
currentIndex = 0;
} else {
break;
}
}
}
So you could just override the update
method to get the controll of sprite animations.