123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- import { _decorator, Component, Label, Node, Sprite, SpriteFrame } from 'cc';
- import { base_ui } from '../../fw/base_ui';
- import { area_item_data } from '../../data';
- const { ccclass, property } = _decorator;
- @ccclass('select_area_item')
- export class select_area_item extends base_ui {
- @property(SpriteFrame) sf_unselected:SpriteFrame = null
- @property(SpriteFrame) sf_selected:SpriteFrame = null
- @property(Node) lab_name:Node = null
- private m_data:area_item_data = null
- private m_callback = null
- private m_index:number = 0
- private m_is_selected:boolean = false
-
- protected start(): void {
- this.onButtonListen(this.node, ()=>{
- if(this.m_callback!=null) {
- this.m_callback(this)
- }
- })
- }
- initView(data:area_item_data,index,call) {
- this.m_data = data
- this.m_callback = call
- this.m_index = index
- this.lab_name.getComponent(Label).string = data.name
- }
- public getData():area_item_data {
- return this.m_data
- }
- public getIndex():number {
- return this.m_index
- }
- public setSelectStatus() {
- this.m_is_selected = true
- this.node.getComponent(Sprite).spriteFrame = this.sf_selected
- }
- public setUnselectStatus() {
- this.m_is_selected = false
- this.node.getComponent(Sprite).spriteFrame = this.sf_unselected
- }
- public getIsSelected():boolean {
- return this.m_is_selected
- }
- }
|