const {ccclass, property} = cc._decorator;
import NetFrame from './NetFrame'

@ccclass
export default class Helloworld extends cc.Component {

    @property(cc.Label)
    label: cc.Label = null;

    @property(cc.Node)
    testNode: cc.Node = null;

    @property
    text: string = 'hello';

    @property(cc.Prefab)
    testPrefab:cc.Prefab = null;

    start () {
        // init logic
        this.label.string = this.text;
    }

    // 11111111
    // onBtnActive(){
    //     this.testNode.active = true;

    //     cc.log('点击了激活按钮', this.testNode);
    //     this.testNode.getComponent(NetFrame).loadLocal('dzq');
    // }

    // onBtnDestroy(){
    //     this.testNode.destroy();
    // }


    onBtnActive(){
        let node = cc.instantiate(this.testPrefab);
        cc.log('点击了激活按钮', node);
        node.position = cc.v3(10,10);
        node.name = 'test';
        // this.testNode.getComponent(NetFrame).loadLocal('dzq');
        node.parent = this.node;
    }

    onBtnDestroy(){
        let node = this.node.getChildByName('test');
        node && node.destroy();
    }

}
