clearInterval()不正常工作。间隔堆叠在彼此
大家好,我一直在setInterval()和clearInterval()函数上遇到麻烦。
我似乎无法弄清楚为什么它不起作用,正在寻找数小时尝试多种解决方案
,我希望用户能够单击一个区域,之后它产生了一个敌人,您杀死了敌人,另一个重生,
我像但我遇到的问题是,当敌人刷新时,它的健康立即下降到0,几乎就像SetIntervals彼此堆叠在一起,因为它重生后,它开始造成双重伤害。
如果有人能给我深入了解,那就太好了!
function selectelwynnforestzone(){
var refreshtankattackinterval = setInterval(tankattackenemy, tankattackspeed);
Codepen链接 https://codepen.io/jonloft/jonloft/pen/pen/eymmyqj
但是只需单击Elwynn森林按钮)
Hello everyone I have been having trouble with the setInterval() and clearInterval() functions.
I can’t seem to figure out why it’s not working, been searching for hours trying multiple solutions
I want the user to be able to click on a zone, afterwards it spawns an enemy, you kill the enemy, another respawns
I have it like this but the problem I am having is that when the enemy refreshes, it’s health immediately drops to 0 and its almost like the setIntervals are stacking on top of each other because after it respawns it starts taking double damage.
If anyone could give me insight on this that would be great!
function selectelwynnforestzone(){
var refreshtankattackinterval = setInterval(tankattackenemy, tankattackspeed);
Codepen link
https://codepen.io/jonloft/pen/eYMmYQj
(It may look a little wonky but just click the Elwynn forest button)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论