import { _decorator, AnimationClip, Sprite, Component, Node, UITransform, Color, SpriteFrame, resources, Layers } from 'cc';
const { ccclass, property } = _decorator;

// @ccclass('dice_animation')
// export class dice_animation extends Component {
//     start() {

//     }

//     update(deltaTime: number) {

//     }
// }

export class dice_dd {

    public static getNode(): Node {

        let node = new Node();

        node.layer = Layers.Enum.UI_2D;//不添加不显示

        // 创建并添加脚本组件
        let component = node.addComponent(dice_domponent);
        // 创建并添加精灵组件
        let sprite = node.addComponent(Sprite);

        return node;
    }
}


export class dice_node extends Node {

    /// 构造函数
    constructor() {
        console.log("sadnhjsanjkdbasjkdbnasjkbdhjasd");

        super();

        this.layer = Layers.Enum.UI_2D;//不添加不显示

        // 创建并添加脚本组件
        let component = this.addComponent(dice_domponent);
        // 创建并添加精灵组件
        let sprite = this.addComponent(Sprite);

        resources.load('internal/default_ui/default_sprite.png/spriteFrame', (err, spriteFrame: SpriteFrame) => {
            const sprite = this.addComponent(Sprite);
            sprite.color = Color.RED;
            sprite.spriteFrame = spriteFrame;
        });
    }


}


@ccclass('dice_node')
export class dice_domponent extends Component {


    start() {

        const uiTf = this.node.getComponent(UITransform);
        uiTf.setContentSize(200, 400);

        // resources.load('internal/default_ui/default_sprite.png/spriteFrame', (err, newSpriteFrame) => {
        //     const sprite = this.node.getComponent(Sprite);
        //     sprite.color = Color.RED;
        //     // sprite.spriteFrame = spriteFrame;
        //     sprite.spriteFrame = newSpriteFrame;
        // });

    }

    update(deltaTime: number) {

    }

}



