Hello. There is a function that moves an object one cell to the right. After animating the movement, you need to save the current position of the object. And the next time you call this function, you need to animate the movement already from the new position of the object.
Here is the function code
public void MoveRight(GameElement element) { TranslateTransform trans = new TranslateTransform(); element.RenderTransform = trans; DoubleAnimation anim1 = new DoubleAnimation(0, Constants.CellSize, TimeSpan.FromSeconds(1)); trans.BeginAnimation(TranslateTransform.XProperty, anim1); element.PositionX += Constants.CellSize; } But, the next time you call this function, the animation still starts from the very first point, despite the changed position of the object.
I tried this way:
DoubleAnimation anim1 = new DoubleAnimation(element.PositionX, element.PositionX + Constants.CellSize, TimeSpan.FromSeconds(1)); But then when you first call the object jumps to the distance element.PositionX , then comes the animation.
Help me please