飞机大战需要背景图,飞机,子弹,敌机
下面写的是css代码实现子弹的运动
for (var i = 0; i < this.objB.arr.length; i++) {
var newArr = this.objB.arr[i].split(‘|‘);//[id|top|left]
var eleB = document.getElementById(newArr[0]);
newArr[1] = parseInt(newArr[1]) - 1; //将上一个的newArr1减1并赋值
// console.log(newArr[1]);
eleB.style.top = newArr[1] + ‘px‘;
this.objB.arr[i] = newArr[0] + ‘|‘ + newArr[1] + ‘|‘ + newArr[2];
if (newArr[1] < 0) {
this.objB.arr.splice(i, 1);
var delEle = document.getElementById(newArr[0]);
delEle.parentNode.removeChild(delEle);
}
console.log(newArr);
}