I'm trying to call a function on click on sprite (sprite is just a picture). Documentation example doesn't work
This is my code, everything except the click event works correctly
import { _decorator, Component, Node } from 'cc';
const { ccclass, property } = _decorator;
@ccclass('NewComponent')
export class NewComponent extends Component {
start() {
let anim = this.getComponent(cc.Animation);
anim.play("anim_pers");
console.log('start');
node.on(cc.Node.EventType.MOUSE_DOWN, function (event) {
console.log('Mouse down');
}, this);
}
update(deltaTime: number) {}
}