Phaser 3 group incX 不是一个函数

伊洛佩兹卢纳

按照文档https://phaser.io/phaser3/api/group我创建了一个group并尝试调用该方法incX

var group = this.add.group();
group.incX(10);

和我Uncaught TypeError: group.incX is not a function事实上,当我打印对象到控制台:

console.log(group);

我没有看到此方法或文档中指定的其他方法。难道我做错了什么?文档是否过时?

卡门·明科夫

听起来很奇怪,但似乎并非 phaser.io 上的所有 Phaser 3 信息都是最新的。您可以在 PhotonStorm 的 GitHub 上获取当前文档并在本地浏览(只需打开文件docs中的任何 html 文件)。

至于代码,假设您希望.incX()增加x组中每个精灵属性,这里有一种方法:

let children = group.getChildren();
children.forEach((child) => {
    if (child instanceof Phaser.GameObjects.Sprite) {
        child.x += 10;
    }
});

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章