Can Storyboard contain multiple animations targeting same property?
Posted: 11 Jul 2017, 05:58
Hi, my game includes multiple animations in a single storyboard, some of which target the same property (although not at the same time). The idea of using a single storyboard is to be able to pause etc. I think this all works fine in WPF, but in Noesis, only the last animation can run.
To illustrate this problem below is a simple example:
To illustrate this problem below is a simple example:
Code: Select all
var storyboard = new Storyboard();
var duration = new Duration(TimeSpan.Parse("0:0:1"));
var x1Animation = new DoubleAnimation() {
To = 800,
Duration = duration
};
var y1Animation = new DoubleAnimation() {
To = 800,
Duration = duration
};
Storyboard.SetTarget(x1Animation, demo1KingCard);
Storyboard.SetTarget(y1Animation, demo1KingCard);
Storyboard.SetTargetProperty(x1Animation, new PropertyPath(Canvas.LeftProperty));
Storyboard.SetTargetProperty(y1Animation, new PropertyPath(Canvas.TopProperty));
storyboard.Children.Add(x1Animation);
storyboard.Children.Add(y1Animation);
var beginTime = TimeSpan.Parse("0:0:1");
var x2Animation = new DoubleAnimation() {
BeginTime = beginTime,
To = 200,
Duration = duration
};
var y2Animation = new DoubleAnimation() {
BeginTime = beginTime,
To = 200,
Duration = duration
};
Storyboard.SetTarget(x2Animation, demo1KingCard);
Storyboard.SetTarget(y2Animation, demo1KingCard);
Storyboard.SetTargetProperty(x2Animation, new PropertyPath(Canvas.LeftProperty));
Storyboard.SetTargetProperty(y2Animation, new PropertyPath(Canvas.TopProperty));
storyboard.Children.Add(x2Animation);
storyboard.Children.Add(y2Animation);