javascript - 如何选择所有 javascripts 对象?
问题描述
这是我的课:
class Player {
static list = new Map()
constructor(id) {
Player.list.set(id, this)
this.id = id;
this.x = 0;
this.y = 0;
...
}
}
我怎样才能循环每个玩家?感谢您的回答
解决方案
由于您使用的是要循环的地图,因此您可以使用以下示例:
Player.list.forEach(player => {
players.update();
players.getUpdatePack();
})
推荐阅读
- ubuntu - 更改 platformio-ide-terminal 中文件夹的颜色
- google-oauth - Dialogflow 帐户链接中断了流程
- hibernate - 我遇到了使用 spring-boot 2.0.2.RELEASE 进行 Hibernate/lucene 搜索的问题
- ms-access - 在 MS Access 2010 中,可以为每个唯一记录输入查询参数吗?
- python-3.x - 无法在 cmd 中将 pip 版本 10.0.1 升级到 18.0
- php - 创建 JSON 文件并显示
- interrupt - 启用外部中断时 STM32L4R5xx 挂起
- git - 返回两次提交,但将最后两次保留在新分支中
- vba - 使用 VBA 进行递归树状解析
- android - MVVMCROSS Xamarin.Android 6.1.2 库导航