我智商爆棚
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

128 lines
2.9 KiB

4 weeks ago
/*
* @Descripttion:
* @version: 1.0.0
* @Author: YeeChan
* @Date: 2020-07-18 13:43:03
*/
import FMViewBase from "../Base/FMViewBase";
/*
* @Descripttion: layout
* @version: 1.0.0
* @Author: YeeChan
* @Date: 2020-07-18 13:43:03
*/
const { ccclass, property, requireComponent, disallowMultiple, menu } = cc._decorator;
@ccclass
// @requireComponent(cc.ScrollView)
@disallowMultiple() //防止多个相同类型(或子类型)的组件被添加到同一个节点
//@menu('FM组件/FMItemLayout')
export default class FMItemLayout extends FMViewBase {
@property({ tooltip: "子节点集合", type: [cc.Node] })
protected itemChilds: cc.Node[] = [];
//自定义标签
protected ad_tag_custom: any = null;
protected itemIndex_custom: number = 0;
//获取更新当前item的回调
private _fmListenerData_custom: FMListener;
//各个节点自定义事件
public EventEnumView_custom: {};
/**
* 广
* @param tag
*/
public setAdTag_custom(tag: any) {
this.ad_tag_custom = tag;
}
protected addEvent_custom(): void {
}
protected removeEvent_custom(): void {
}
protected initView_custom(): void {
}
/**
*
* @param _listener
*/
public setFMListenerUpdate_custom(_listener: FMListener) {
this._fmListenerData_custom = _listener;
}
/**
* index
* @param id
*/
public setItemIndex_custom(id: number) {
this.itemIndex_custom = id;
if (this._fmListenerData_custom) {
let childSum = this.itemChilds.length;
for (let index = 0; index < childSum; index++) {
let sum = this.itemIndex_custom * childSum + index;
let data = callFM_custom(this._fmListenerData_custom, sum);
this.updateDataItemByIndex_custom(data, index);
}
}
// console.log("更新第几个 " + id);
// (this.itemChilds[0].getChildByName("label").getComponent(cc.Label)).string = id + "";
}
/**
*
* @param data
* @param childIndex
*/
protected updateDataItemByIndex_custom(data: any, childIndex: number) {
LogUtils.log_custom("FMItemLayout -> updateDataItemByIndex -> data", data);
}
/**
*
*/
public getItemIndex_custom(): number {
return this.itemIndex_custom;
}
public getPointX_custom(): number {
return this.node.x;
}
public getPointY_custom(): number {
return this.node.y;
}
public setPointX_custom(x: number): void {
this.node.x = x;
}
public setPointY_custom(y: number): void {
this.node.y = y;
}
/**
*
*/
public getItemChildrenCount_custom(): number {
return this.itemChilds.length;
}
}