请问各位大大..PictureBox1碰撞侦测PictureBox2程式里的抛物线的碰撞侦测都没有反应.请问是程式码哪边有错误碰撞侦测我是放在Timer1_Tick这里.是位置放错还是抛物线的碰撞侦测不能用那种碰撞侦测方式.
Public Class Form1
'---------- Local structures ----------
'Positions [位置的变数]
Structure struc_pos
Dim x, y As Integer 'Current position [目前的 x,y]
Dim ini_x, ini_y As Integer 'Initial position [抛物线参考的最初 x,y,就是物理中表示的 x0,y0]
Dim ang As Single 'Current angle [目前的角度,为碰撞时可转换]
Dim vx, vy As Single 'Current velocity [目前的速度分量]
Dim ini_vx, ini_vy As Single 'Initial velocity [一开始的 速度分量,就是物理中表示的 vx0,vy0]
Dim ini_v As Single 'Initial velocity [一开始的速度]
Dim g As Single 'Gravity constant [重力常数]
End Structure
'---------- Local constants ----------
'Initial positions
Const user_ini_v As Single = 90 '[设定一开始的速度(可调整)]
Const user_ini_x As Integer = 50, user_ini_y As Integer = 500 '[图片一开始的座标(可调整)]
'---------- Local variables ----------
'Graphics [绘图]
Dim g As System.Drawing.Graphics
Dim dstRect, srcRect As Rectangle
'List [清单]
Dim listPic As New List(Of Image) 'List of picture
Dim listAng As New List(Of Integer) 'List of angle
'Collection [集合]
Dim collRep As New Collection
'Positions [宣告座标的巢状结构]
Dim pos As struc_pos
'Flags [旗标]
Dim stat_moving As Integer 'Status (Pausing->0, Moving->1) [纪录是否在移动]
Dim stat_ang, max_ang As Integer 'Angle [角度(DEG),与最大值]
Dim passedTime, multiTi As Single 'Time [已经过时间,与时间加倍量]
'Help texts
Const hlp_1 As String = "(1) 按 ""上"",""下"" 切换角度" & vbNewLine & "(2) 按 ""空白键"" 开始发射/停止" & vbNewLine & vbNewLine & "当物体碰撞到底下边缘才会消失"
Private Sub Form1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown
local_kc_dir(e.KeyCode)
End Sub
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim i As Integer
'--- Variables ---
'Position
With pos
.g = 9.8
.ini_v = user_ini_v
End With
'Status
stat_moving = 0
stat_ang = 6 '[设定一开始是第三张图片,30度的]
'Time
multiTi = 15 '[时间加倍量,太低图片会跑很慢]
'--- List of Images ---
'[读取图片,并读取角度值]
max_ang = -1
For i = 0 To 360 Step 15
listPic.Add(Image.FromFile("00_" & i & ".gif"))
listAng.Add(i)
max_ang += 1
Next
'--- Obj. ---
'PictureBox1
local_renew_resetpic()
PictureBox1.Visible = False
'Timer1
Timer1.Interval = 50
'--- Sub ---
local_change_pic()
End Sub
Private Sub Form1_Paint(ByVal sender As System.Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles MyBase.Paint
dstRect = Me.ClientRectangle
srcRect = dstRect
g = e.Graphics
'--- Picture ---
dstRect = New Rectangle(New Point(pos.x, pos.y), PictureBox1.Size)
g.DrawImage(PictureBox1.Image, dstRect, srcRect, GraphicsUnit.Pixe ..
访客只能看到部份内容,免费 加入会员 或由脸书 Google 可以看到全部内容