import { _decorator, Component, Label, Node } from 'cc';
import { att_ani_data } from '../../../data/data';
import { tools } from '../../tools';
const { ccclass, property } = _decorator;

@ccclass('attributes_animation')
export class attributes_animation extends Component {
    @property(Node) btn_add_animation:Node = null;
    @property(Node) lab_name:Node = null;
    private call_back = null;
    private _ani_list:att_ani_data[] = []
    protected start(): void {
        let self = this;
        this.btn_add_animation.on(Node.EventType.TOUCH_END,()=>{
            tools.show_add_animation(this._ani_list,(list:att_ani_data[])=>{
                self._ani_list = list;
                self.change()
            })
        })
    }

    public update_att(ani_list:att_ani_data[]){
        this._ani_list = ani_list;
        this.lab_name.getComponent(Label).string =  this._ani_list.length>0?"添加动画":"空"
    }

    public initView(call){
        this.call_back = call;
    }

    change(){
        if(this.call_back!=null){
            this.call_back(this._ani_list)
        }
    }

}


