我正在尝试从我的游戏中完全删除一个精灵(充当死亡角色)。我在网上能找到的只有:
sprite.parent.removeChild(sprite);
Run Code Online (Sandbox Code Playgroud)
当我这样做时,精灵停止渲染,但我很确定精灵还在那里,我的碰撞仍然被检测到,它导致了很多问题。如何从场景中完全移除精灵?
所以我是 webpack 的新手,我正在尝试配置它以使用 esnext 私有方法和字段。我还没有指定加载器,但我不确定使用哪一个。目前,我的webpack.config.js文件如下所示:
const path = require("path");
module.exports = {
entry: "./src/Rorke.js",
output: {
path: path.resolve(__dirname, "dist"),
filename: "rorke.js"
}
};
Run Code Online (Sandbox Code Playgroud)
当我运行时webpack,它抛出一个错误:
Unexpected character '#'
Rorke.js 看起来像这样:
import Sprite from "./Sprite";
const test = new Sprite(0, 0);
Run Code Online (Sandbox Code Playgroud)
和 Sprite.js 看起来像:
export default class Sprite {
#x;
#y;
constructor(x, y) {
this.#x = x;
this.#y = y;
}
}
Run Code Online (Sandbox Code Playgroud)
当我使用没有私有字段的常规 es6 类时,它可以正常工作,但不能用于私有字段。
我应该使用哪个装载机/我该如何解决这个问题?
我真的很难理解如何使用 PIL 操作图像。我试图返回匹配某种颜色的所有像素的 x 和 y 坐标。所以在伪代码中:
img = ImageGrab.grab(bbox)
pixels = img.getdata()
for i in range(len(pixels)):
if pixels[i] == (255, 0, 0, 255) # red for example:
coords.append(pixels[i].x)
coords.append(pixels[i].y)
Run Code Online (Sandbox Code Playgroud)
我只是不知道如何在附加 x 和 y 的最后一点做。有这个功能吗?
谢谢!