下面是完整的代碼:如何讓形狀獨立移動而不出現抖動?
GraphicsWindow.Clear()
GraphicsWindow.CanResize = "false"
GraphicsWindow.Height = Desktop.Height-200
GraphicsWindow.Width = Desktop.Width-200
scount = Math.GetRandomNumber(25)
For s = 1 To scount
Shx[s] = Math.GetRandomNumber(GraphicsWindow.Width-100)
Shy[s] = Math.GetRandomNumber(GraphicsWindow.Height-100)
shsize[s] = Math.GetRandomNumber(50)
Sh[s] = Shapes.AddEllipse(shsize[s],shsize[s])
Shapes.Move(Sh[s],Shx[s],Shy[s])
EndFor
loop:
For s = 1 to scount
op[s] = Math.GetRandomNumber(2)
If op[s] = 1 Then
vel[s] = .5
EndIf
If op[s] = 2 Then
vel[s] = -.5
EndIf
Shx[s] = Shx[s] + vel[s]
Shy[s] = Shy[s] + vel[s]
Shapes.Move(Sh[s],Shx[s],Shy[s])
EndFor
Goto loop
我的猜測是這個問題在這裏:
op[s] = Math.GetRandomNumber(2)
If op[s] = 1 Then
vel[s] = .5
EndIf
If op[s] = 2 Then
vel[s] = -.5
EndIf
什麼我需要做的,使形狀的獨立方向移動沒有他們引起的顫動?
如果你想語句來執行無論每秒幀數如何,速度都保持不變,您只需根據每秒幀數編輯速度即可。所以可以說,無論幀是什麼,每秒鐘總是需要5像素移動,而每秒移動5個像素,這就是每秒移動的像素數量。所以如果你有每秒10幀,你會移動0.5像素每一幀增加到5像素在那秒。 :-希望這有助於。 – Matthew