尝试在C#的运行时创建动画 [英] Trying to create animation at runtime in C#

查看:167
本文介绍了尝试在C#的运行时创建动画的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,

我想用C#创建类似Flash的动画,该动画需要用户输入,然后绘制该动画的更新.
我创建了一个Windows Forms应用程序,该应用程序从用户那里获取输入并显示文本数据,但是我也想在动画中对其进行模拟.
例如,如果用户希望看到n个球在某个路径中移动,则输入n的值,然后将动画调整为与n个球一起玩.
有没有办法做到这一点?我什至在使用正确的技术吗?

如果这个问题很愚蠢,请当我是初学者时接受我的意见.

Hello,

I would like to create a Flash-like animation in C# that takes user input and then draws updates that animation.
I have created a Windows Forms application that takes input from the user and displays the textual data, but I would like to simulate it in an animation as well.
For e.g., if a user wants to see n number of balls move in a certain path, he enters the value for n and the animation is adjusted to play with n balls.
Is there a way to do this? Am I even using the right technology for it?

In case, this question is stupid, please bear with me as I am a beginner.

推荐答案

如果您希望动画根据文本进行更新,则可以创建WPF 动画,并在您的TextChanged事件的事件处理程序中对其进行更新TextBox.
If you want animations that are updated according to a text, you can create a WPF animations and, update them in the event-handler of the TextChanged event of your TextBox.


我认为WPF更适合动画设计,但是如果您真的想使用Forms,那是相当可行的.您可以在我过去的解决方案中找到一些基本想法,请参见如何进行图像动画 [^ ].

球动画是一个简单的案例(我碰巧做了这样的事情).根据当前时间和计算出的模型,使用Graphics实例作为该方法的参数在Control.OnPaint中渲染球.渲染更新是通过调用方法Control.Invalidate触发的.
—SA
I think WPF is better designed for animations, but if you really want using Forms, it''s quite doable. You can find some basic ideas in my past solution, see how to do image animation[^].

You ball animation is a simple case (and I happened to do something like this). Balls are rendered in Control.OnPaint using an instance of Graphics passes as a parameter to this method, based on current time and the calculated model. The rendering update is triggered by a call to the method Control.Invalidate.

—SA


这篇关于尝试在C#的运行时创建动画的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆