本文介绍了增加变量值的定时器事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写一个非常基本的程序,我希望球遵循抛物线曲线.我的想法是设置一个计时器以一定的间隔打勾,并将时间设置为我在方程中使用的变量,该变量也将是我的 x 值.

I'm working on a very basic program where I want a ball to follow a parabolic curve. My idea is to set a timer to tick with a certain interval and set the time as an variable which I use in my equation which will also be my x-value.

我创建了一个事件 timer_Tick.如何在每次计时器滴答时增加 X 的值?

I've created an event timer_Tick. How can I increase the value of X each time the timer ticks?

推荐答案

private int myVar= 0;//private field which will be incremented

void timer_Tick(object sender, EventArgs e)//event on timer.Tick
{
            myVar += 1;//1 or anything you want to increment on each tick.
}

这篇关于增加变量值的定时器事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-23 13:46