Hi!
I want to change colors of polygon shapes when they are clicked.
My experiment works “offline” but not online.
Here is my code in the each frame component (Auto->JS):
Python:
for h in houses:
if mouse.isPressedIn(h) and h.fillColor == "red":
clicked = True
h.fillColor = "white"
core.wait(0.15)
elif mouse.isPressedIn(h) and h.fillColor == "white":
clicked = True
h.fillColor = "red"
core.wait(0.15)
JS:
for (var h, _pj_c = 0, _pj_a = houses, _pj_b = _pj_a.length; (_pj_c < _pj_b); _pj_c += 1) {
h = _pj_a[_pj_c];
if ((mouse.isPressedIn(h) && (h.fillColor === "red"))) {
clicked = true;
h.fillColor = "white";
core.wait(0.15);
} else {
if ((mouse.isPressedIn(h) && (h.fillColor === "white"))) {
clicked = true;
h.fillColor = "red";
core.wait(0.15);
}
}
}
Maybe it has something to do with the “and” operator? In another experiment without the “and” it works online. I also tried it with setFillColor but this also did not work.
Thank you very much for any help!