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

@ccclass('add_animation_item')
export class add_animation_item extends Component {
    @property(Node) lab_name:Node = null;
    private call_back = null;
    private m_data:att_ani_data = null;
    private m_index:number  =0;
    public initView(data:att_ani_data,call,index){
        this.call_back = call;
        this.m_index = index;
        this.m_data = data;
        this.lab_name.getComponent(Label).string = this.m_data.ani_name;
        this.node.on(Node.EventType.TOUCH_END,()=>{
            if(this.call_back!=null){
                this.call_back(this)
            }
        })
        this.unSelectStatus()
    }

    public getIndex(){
        return this.m_index;
    }

    public selectStatus(){
        this.node.getComponent(Sprite).color = Color.BLUE
    }

    public unSelectStatus(){
        this.node.getComponent(Sprite).color = Color.GRAY
    }

    public getData(){
        return this.m_data;
    }
}


