当前位置:网站首页>Starting from scratch (IV) enemy aircraft flying out of the border disappear automatically
Starting from scratch (IV) enemy aircraft flying out of the border disappear automatically
2022-06-11 06:46:00 【Dare you look at the avatar for three seconds?】
Problems encountered

As shown in the figure , In order to realize the random increase of enemy aircraft and the first random flight of players on the stage, do you know , When checking the console, I found , When the enemy plane flies over the stage, it will not disappear automatically , So that the program will take up too much memory space , The situation is somewhat similar to the memory leak that is not released in time when dynamic memory allocation is implemented , So when the computer slows down at visible speed , How to make the enemy aircraft disappear automatically becomes more and more difficult
Before that, first understand a few concepts
Every enemy plane is loaded by us html One of the nodes in , Or labels
understand dom node
document object model---- Document object model
Our need is , After the enemy aircraft flies over the stage, the corresponding... Will be deleted automatically html node , Before deleting, we need to find a way to get the corresponding node of the aircraft flying out of the stage
dom The attribute acquisition problem of the node
Get the properties of all nodes ( Height or something ) Not directly in js Inside point , You can't get , This also applies jq Why
But the input field can be clicked directly value
Specific code :
// When you leave the stage, remember to remove dom node
setInterval(function(){
for(i=0;i<enemy.length;i++){
var tmp_enemy=parseFloat($(enemy[i]).css("top"));
var tmp_stage=$(stage).height();
// console.log(tmp_enemy);
// console.log(typeof($(tmp_stage).height()));
if(tmp_enemy>tmp_stage){
$(enemy[i]).remove();
console.log(" Removed successfully ")
}
}
},500)
边栏推荐
- 通过两种方式手写一个消息队列
- 洛谷P1091合唱队形(最长上升子序列)
- 022 basic introduction to redis database 0
- Using Metasploit Trojan horse for remote control
- 节流和防抖
- PHP processing tree and infinite processing
- Metasploitabile2 target learning
- Flat design, blog website (VIII) code source code
- Examinelistactivity of Shandong University project training
- 解决ffmpeg获取AAC音频文件duration不准
猜你喜欢

Sohu employees encounter wage subsidy fraud. What is the difference between black property and gray property and how to trace the source?

Differences between FindIndex and indexof

Warning: Each child in a list should have a unique “key“ prop.

开源漫画服务器Mango

572. subtree of another tree

NPM upgrade: unable to load file c:\users\administrator\appdata\roaming\npm\npm-upgrade ps1

Using Metasploit Trojan horse for remote control

Do you use typescript or anyscript

Won't virtual DOM be available in 2022? Introduction to virtual Dom and complete implementation of diff and patch

Use of qscriptengine class
随机推荐
Pytest自动化测试-简易入门教程(01)
统计某次操作(函数)耗时时长
CCS安装编译器的方法
JVM from getting started to abandoning 1: memory model
Learn a trick to use MySQL functions to realize data desensitization
【Matlab WSN通信】A_Star改进LEACH多跳传输协议【含源码 487期】
Autojs, read one line, delete one line, and stop scripts other than your own
Unity 全景漫游过程中使用AWSD控制镜头移动,EQ控制镜头升降,鼠标右键控制镜头旋转。
Pytest automated test - easy tutorial (01)
无心剑汉英双语诗001.《爱》
Handwriting promise [03] - realize multiple calls and chain calls of then method
Handwritten promise [05] - exception capture of promise method and optional parameters of then method implementation
UEFI finding PCI devices
节流和防抖
235-二叉搜索树的最近公共祖先
break,continue有什么区别和用法?
CCS method of installing compiler
Convert text label of dataset to digital label
不同VLAN间的通信
Why don't we have our own programming language?