// Learn TypeScript: // - https://docs.cocos.com/creator/manual/en/scripting/typescript.html // Learn Attribute: // - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html // Learn life-cycle callbacks: // - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html const {ccclass, property} = cc._decorator; @ccclass export default class NewClass extends cc.Component { // @property(cc.Label) // label: cc.Label = null; // @property // text: string = 'hello'; onLoad () { this.node.on("mousedown", this.show, this); } show() { //1.javascript寫法 // var node = cc.find("Canvas/小叮噹/名字"); // var comp1 = node.getComponent(cc.Label); //2.Typescript寫法 let node:cc.Node = cc.find("Canvas/小叮噹/名字"); let comp1:cc.Label = node.getComponent(cc.Label); comp1.string = "小叮噹"; } // onLoad () {} start () { } // update (dt) {} }