I have tried translating (moving) a canvas but I'm having trouble with the timers.
I tried 2 different methods:
First method was with the BeginAnimation
function, and the second with DispatcherTimer
ticks, but they're both very unreliable.
I need to monitor every step of the translation. With the first method I tried (BeginAnimation
), I did the Collision Detection logic in the Changed
event, and with the second method (DispatcherTimer
) I am doing the Collision Detection logic in the Tick
event of the timer.
The problem is that both are very unreliable. In the sense that, in my collision detection logic, the canvas should stop translating when its TranslateTransform
's Y
property is <= 0 (technically, if it is monitoring every step, it should stop at 0 every time) , but with both methods I tried, it varies when it stops. For example, sometimes it stops at 0, sometimes at -1, -2, -3 and sometimes even at -4.
So what's with the discrepancies ? Why doesn't it monitor every step of the way like it's supposed to ?
What can I do to animate this canvas and really monitor every step of the way? An I mean every step...every pixel it moves