Move images with timer

后端 未结 1 1992
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-29 03:53

I\'ve written a code to move images from specific locations with timer and pictureBox.

But my code doesn\'t work properly because images don\'t

1条回答
  •  一整个雨季
    2021-01-29 04:06

    To be honest, because I'm not entirely sure what it's actually doing I'm not going to offer a picturebox solution. Animation, timing etc is, in my experience, never easy to implement using timers, primarily because the kind of timers you're using don't guarantee that they fire exactly when they should - since they require the windows message pump to be empty for the timer message to get through. It's not that it's impossible or anything, indeed my first work with animation was also done with timers.

    If the code you're writing is to satisfy some exercise in computer animation (i.e. homework?) then you will have to learn this as part of trying to solve the problem or somebody more generous than I will no doubt give you the answer.

    For my part, do this instead in WPF and use its animation and storyboard functionality.

    This way you can specify your timelines and paths (linear paths are simple with WPF) and then you can use events for the decisions. Managing the actual animation then is no longer your problem - you just specify where things need to be and how long they should take.

    The final result is likely to be far superior on screen as well, since WPF uses a 'proper' rendering loop akin to the kind of thing used in games.

    Sorry if this answer isn't helpful.

    0 讨论(0)
提交回复
热议问题