游戏碰撞如何判断只加一分
演示地址
关键代码如下;全部代码可见index.html文件
function getScore(){ //碰撞判断并赋分
myApp.zuobiao.user();
myApp.zuobiao.bomb();
myApp.zuobiao.gift();
if(sourceMaxX<giftMinX || sourceX>giftMaxX || sourceMaxY<giftMinY || sourceY>giftMaxY){
andS = false;
}else{
andS = true;
gift.remove();
};
/*if(sourceX<giftMinX || sourceX>giftMaxX || sourceY<giftMinY || sourceY>giftMaxY){
andS = false;
}else{
andS = true;
}*/
if(andS){
score=score+1;
andS = false;
$("#scoreText").html(score);
}
};