利用c#两个label控件和timer时钟实现射气球这么个程序,label1为箭,label2为气球,气球需实现上下循环移动,箭由键盘控制,单击空格箭发射出去,从左往右,气球则从下往上,当箭碰到气球时,则弹出对话框:“射中啦”,结束退出
主要就是label2气球上下循环移动难点,和碰撞弹出对话框,球解答
循环
int step=1;
if(label2.top<=0)
step=1;
else if(label2.top+lebel2.heigth>=height)
step=-1;
label2.top+=step;
碰撞:label1和label2有公共区域
if( label1.left+label1.width >= label2.left) && (label1.top >label2.top && label1.top+label1.height <=label2.top+label2.height)