
import { _decorator, Component, Node, Layers, ButtonComponent, Button, Vec3, SpriteFrame, Sprite } from 'cc';
const { ccclass, property } = _decorator;

/**
 * Predefined variables
 * Name = NewComponent
 * DateTime = Tue Sep 21 2021 14:55:28 GMT+0800 (中国标准时间)
 * Author = muxiandong
 * FileBasename = NewComponent.ts
 * FileBasenameNoExtension = NewComponent
 * URL = db://assets/NewComponent.ts
 * ManualUrl = https://docs.cocos.com/creator/3.3/manual/zh/
 *
 */
 
@ccclass('NewComponent')
export class NewComponent extends Component {
    // [1]
    // dummy = '';

    // [2]
    // @property
    // serializableDummy = 0;

    @property(SpriteFrame)
    targetSP : SpriteFrame;

    start () {
        // [3]

        let node = new Node();
        node.layer = Layers.Enum.UI_2D;

        this.node.addChild(node);

        const button = node.addComponent(Button);
        node.setPosition(new Vec3(100, 100 ,0));

        const sprite = node.addComponent(Sprite);
        sprite.sizeMode = Sprite.SizeMode.CUSTOM;
        sprite.spriteFrame = this.targetSP;

        
    }

}
