這問題是,能不能用這個表單(也不一定是表單)來做出這個(不知怎麼問)
放在表單的背景非常大,滑鼠移到邊界然後畫面會移動,像即時戰略遊戲
那樣滑鼠碰表單邊界會移動這個畫面。
如果有辦法 能貼一下程式碼?
2006-10-05 17:58:34 · 1 個解答 · 發問者 Mr.Tzeng 2 in 電腦與網際網路 ➔ 程式設計
'版本:VB6,表單置1個TimerDim P As Picture, W&, H&, L&, T&, K%, M&, N&, A%, B%Private Sub Form_Load() Timer1 = False Timer1.Interval = 50 '移動的速度 K = 10 '移動的距離 AutoRedraw = True ScaleMode = 3 W = ScaleWidth H = ScaleHeight '載入圖檔(請注意:圖檔寬高必須比表單大) Set P = LoadPicture("C:\Test.bmp") '圖檔寬高M,N M = P.Width * 567 \ 1000 \ Screen.TwipsPerPixelX N = P.Height * 567 \ 1000 \ Screen.TwipsPerPixelY PaintPicture P, 0, 0, W, H, 0, 0, W, HEnd SubPrivate Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single) If X < 4 Then A = 0 ElseIf X > W - 4 Then A = 1 Else A = 3 End If If Y < 4 Then B = 0 ElseIf Y > H - 4 Then B = 1 Else B = 3 End If Timer1 = (A < 3 Or B < 3)End SubPrivate Sub Form_Unload(Cancel As Integer) Set P = NothingEnd SubPrivate Sub Timer1_Timer() Static I&, J& Select Case A Case 0 If L Then If L - K > 0 Then L = L - K Else L = 0 End If End If Case 1 If M - W > L Then If L + K > M - W Then L = M - W Else L = L + K End If B = True End If End Select Select Case B Case 0 If T Then If T - K > 0 Then T = T - K Else T = 0 End If End If Case 1 If N - H > T Then If T + K > N - H Then T = N - H Else T = T + K End If End If End Select If I <> L Or J <> T Then PaintPicture P, 0, 0, W, H, L, T, W, H I = L: J = T End IfEnd Sub
2006-10-06 13:31:40 · answer #1 · answered by W.J.S. 7 · 0⤊ 0⤋