官方实力项目中的 example/lib/animation_state_events.dart里面
controller.animationState
.setAnimationByName(0, "walk", true)
.setListener((type, trackEntry, event) {
print("Walk animation event $type");
});
controller.animationState.addAnimationByName(0, "jump", false, 2);
controller.animationState
.addAnimationByName(0, "run", true, 0)
.setListener((type, trackEntry, event) {
print("Run animation event $type");
});
controller.animationState.setListener((type, trackEntry, event) {
if (type == EventType.event) {
print(
"User event: { name: ${event?.getData().getName()}, intValue: ${event?.getIntValue()}, floatValue: intValue: ${event?.getFloatValue()}, stringValue: ${event?.getStringValue()} }");
}
});
只有最后一个方法回调会走,前面两个方法的回调都不会触发,如何只针对某一个动画来监听事件呢