import { _decorator, Component, Node, UITransform, Vec3 } from 'cc';
import { event_item_show_question_select_item, ui_att_item } from '../../../data/data';
import { gameManager } from '../gameManager';
import { tools } from '../../tools';
const { ccclass, property } = _decorator;

@ccclass('btn_question_item')
export class btn_question_item extends Component {
    @property(Node) btn_click:Node = null;
    private m_data:ui_att_item = null;
    private mCallBack = null;
    private mEventData:event_item_show_question_select_item = null;
    public initView(data:ui_att_item,event_data:event_item_show_question_select_item,index:number,call){
        this.mCallBack = call;
        this.mEventData = event_data;
        if(data===null){
            tools.showToast("配置问题选择错误！")
        }else{
            this.m_data = data;
            this.init()
        }
    }

    init(){
        gameManager.initUiBaseAtt(this.node,this.m_data)
        this.node.on(Node.EventType.TOUCH_END,()=>{
            if(this.mCallBack!=null){
                this.mCallBack(this.mEventData)
            }
        })
    }

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


