Hi, I’ve forked @Will’s Flappy Bird and I am editing it. When you click, the bird entity rotates upwards by around 20°, then falls down, angling it to face straight down. One of the things I want to do is rotate the bird
entity back up when it is facing this direction, but I don’t know how to go about this. Here is where (I think) the rotation starts when you click. (Sorry if it’s the wrong place):
this.flapListener = this.flap.bind(this);
window.addEventListener('mousedown', this.flapListener, { passive: false });
window.addEventListener('touchstart', this.flapListener, { passive: false });
this.on('enable', function () {
window.addEventListener('mousedown', this.flapListener, { passive: false });
window.addEventListener('touchstart', this.flapListener, { passive: false });
this.state = 'getready';
app.fire('sine:start');
});
this.on('disable', function () {
window.removeEventListener('mousedown', this.flapListener, { passive: false });
window.removeEventListener('touchstart', this.flapListener, { passive: false });
});
};
Bird.prototype.reset = function () {
var app = this.app;
this.velocity = 0;
this.state = 'getready';
this.entity.setPosition(this.initialPos);
this.entity.setRotation(this.initialRot);
app.fire('bird:flapstart');
};
Bird.prototype.flap = function (event) {
var app = this.app;
if (event) {
// Prevent the function from being called twice when a tap generates
// both a mousedown and a touchstart event
event.preventDefault();
}
Thanks for any help, and please tell me if there’s any other code that needs to be shown