const {ccclass, property} = cc._decorator;
cc.debug.setDisplayStats(false);
@ccclass
export default class Helloworld extends cc.Component {
@property(cc.Label)
label: cc.Label = null;
@property(cc.Node)
mousenode: cc.Node = null;
@property
text: string = 'hello';
onLoad(){
cc.game.canvas.style.cursor = "none";
this.node.on(cc.Node.EventType.MOUSE_MOVE,(move:cc.Touch)=>{
console.log(move.getLocation());
this.mousenode.setPosition(this.node.convertToNodeSpaceAR(move.getLocation()));
})
}
start () {
// init logic
this.label.string = this.text;
}
}
完美,哈哈哈




你这个适合拖动,如果始终要让鼠标图片跟随,应该直接赋予鼠标位置给节点

