【发布时间】:2018-11-22 18:27:57
【问题描述】:
我对编程很陌生,我知道这是一个简单的答案,但我一辈子都想不通。
public float getCurrentY()
{
float CurrentY = API.Extension.ReadFloat(Variables.CIT_PLAYER_Y_COORD);
return CurrentY;
}
当我选中切换框时,它会获取当前的 Y
private void CITFlightTestToggle_CheckedChanged(object sender, EventArgs e)
{
if (CITFlightTestToggle.Checked == true)
{
getCurrentY();
}
else if (CITFlightTestToggle.Checked == false)
{
}
}
我基本上想要玩家检查切换框时当前原因的值,然后将来自轨迹栏的值添加到该存储值上。问题是当您移动轨迹栏时它会不断获取 currentY,并且由于我正在添加它,因此当前 Y 一直在变化。
private void CITFlyingHeightTrackBar_Scroll_1(object sender, ScrollEventArgs e)
{
float diviedflyingheight = CITFlyingHeightTrackBar.Value / 10f;
float current_num = getCurrentY();
float flyingheightadded = current_num + diviedflyingheight;
if (CITFlightTestToggle.Checked == true)
if (levelchecktext == Variables.CIT_LVL_GREAT_CLOCK_A)
{
API.Extension.WriteFloat(Variables.CIT_GCA_Y_COORD, (flyingheightadded));
}
else
{
}
}
提前致谢
【问题讨论】:
-
一个“get”类型的调用应该是一个函数。 CurrentY 听起来不应该是一个字符串。
public float GetCurrentY()可能应该是这样写的,并让它返回值。摆脱 CITCurrentYString ,因为您只有该方法的本地,因此您永远无法使用该值。
标签: c# function floating-point