level 1
山浦未央岁月CI
楼主
B.Bottom为球
Q1为方块
B撞到Q1的上下左右都要反弹
Vy为垂直方向 +向下 -向上
Vx为水平方向 +向右 -向左
If B.Bottom > Q1.Top And B.Left > Q1.Left And B.Right < Q1.Right And B.Bottom < Q1.Bottom Then
Vy = -Math.Abs(Vy)
End If
If B.Top < Q1.Bottom And B.Left > Q1.Left And B.Right < Q1.Right And B.Top > Q1.Top Then
Vy = Math.Abs(Vy)
End If
If B.Right > Q1.Left And B.Top < Q1.Top And B.Bottom > Q1.Bottom And B.Right < Q1.Right Then
Vx = -Math.Abs(Vx)
End If
If B.Left < Q1.Right And B.Top < Q1.Top And B.Bottom > Q1.Bottom And B.Left > Q1.Left Then
Vx = Math.Abs(Vx)
End If
用我这样定义执行出来的结果,有时后会没反弹反而穿了过去
请问各位大神问题出在哪了?
还有是否能用别的方法写?
2015年10月24日 16点10分
1
Q1为方块
B撞到Q1的上下左右都要反弹
Vy为垂直方向 +向下 -向上
Vx为水平方向 +向右 -向左
If B.Bottom > Q1.Top And B.Left > Q1.Left And B.Right < Q1.Right And B.Bottom < Q1.Bottom Then
Vy = -Math.Abs(Vy)
End If
If B.Top < Q1.Bottom And B.Left > Q1.Left And B.Right < Q1.Right And B.Top > Q1.Top Then
Vy = Math.Abs(Vy)
End If
If B.Right > Q1.Left And B.Top < Q1.Top And B.Bottom > Q1.Bottom And B.Right < Q1.Right Then
Vx = -Math.Abs(Vx)
End If
If B.Left < Q1.Right And B.Top < Q1.Top And B.Bottom > Q1.Bottom And B.Left > Q1.Left Then
Vx = Math.Abs(Vx)
End If
用我这样定义执行出来的结果,有时后会没反弹反而穿了过去
请问各位大神问题出在哪了?
还有是否能用别的方法写?