cocoscreator版本2.4.3
新建typescript helloworld项目,Helloworld脚本改为以下代码:
const {ccclass, property} = cc._decorator;
@ccclass
export default class Helloworld extends cc.Component {
@property(cc.Label)
label: cc.Label = null;
@property
text: string = 'hello';
start () {
// 注册鼠标事件
this.node.on(cc.Node.EventType.MOUSE_DOWN, this.onMouseDown, this, true);
this.node.on(cc.Node.EventType.MOUSE_MOVE, this.onMouseMove, this);
this.node.on(cc.Node.EventType.MOUSE_UP, this.onMouseUp, this);
}
// 鼠标按下
private onMouseDown(event: cc.Event.EventMouse): void {
console.log("onMouseDown");
}
// 鼠标移动
private onMouseMove(event: cc.Event.EventMouse): void {
console.log("onMouseMove");
}
// 鼠标松开
private onMouseUp(event: cc.Event.EventMouse): void {
console.log("onMouseUp");
}
}
浏览器运行,按下鼠标,会触发鼠标按下事件,也会触发鼠标移动事件,问题是我鼠标根本没动!!什么原因?