Hi, I’m having issues moving pipes depending on a random number generated on this Flappy Bird game. The code I have tried is here:
var movePipes2 = function() {
var rnd = Math.random();
var item = this.app.root.findByPath(Root/Pipes);
if (rnd > 0 < 0.33) {
item.translateLocal(1, 0.1, 0);
}
if (rnd > 0.33 < 0.66) {
item.translateLocal(2, 0.1, 0);
}
if (rnd > 0.66 < 1) {
item.translateLocal(3, 0.1, 0);
}
};
But this does not seem to be doing anything? I have tried other things, like instead of using translateLocal, I used setLocalPosition, and setPosition, but none of these have seemed to work.
You have a few issues regarding this specific code.
You have created two function objects in global space that have the same name. In movePipes.js and pipe-height.js. This means in the best case, one function is going to override the other.
You are not calling that function anywhere in the code base so it doesn’t matter what’s in the function because it is not being executed.