Answered
removeEventListener(
I'm developing a program that rotates when I put the mouse on the gogogo button and stops when I click the mouse
The rotation was successful, but the stop failed
I want to know how to modify it
/////////// animate cc (canvas)
The rotation was successful, but the stop failed
I want to know how to modify it
/////////// animate cc (canvas)
//////////////////////////////////////////////////////////////////////////////////////////////
this.stop();
/////////////////////////////////////////////////////
var gunx = this.gun.x;
var guny = this.gun.y;
/////////////////////////////////////////////////////
var cx = this.cen.x;
var cy = this.cen.y;
var a = 80;
var b = 80; //초기쎄타각도 잡기
/////////////////////////////////////////////////////
////////////////////////////////////////////////////
var tgun = 3.14;
function gun_fnc() {
this.gun.x = cx + a * Math.cos(tgun);
this.gun.y = cy + b * Math.sin(tgun);
tgun = tgun + 0.8;
}
/////////////////////////////////////////////////////////////////////////////////
// mouseover
/////////////////////////////////////////////////////////////////////////////////
var frequency = 3;
stage.enableMouseOver(frequency);
this.gogogo.addEventListener("mouseover", fl_MouseOverHandler_3.bind(this));
function fl_MouseOverHandler_3() {
this.gun.addEventListener("tick", gun_fnc.bind(this));
}
/////////////////////////////////////////////////////////////////////////////////
// click
/////////////////////////////////////////////////////////////////////////////////
this.gogogo.addEventListener("click", gogogo_MouseClickHandler.bind(this));
function gogogo_MouseClickHandler() {
this.gun.removeEventListener("tick", gun_fnc); // fail (1)
this.gun.removeEventListener("tick", gun_fnc.bind(this)); // fail (2)
this.gun.x = gunx;
this.gun.y = guny;
}
