31 lines
976 B
TypeScript
Raw Normal View History

2022-08-26 16:48:17 +08:00
import ScreenResize from "../ScreenResize";
const { ccclass, property } = cc._decorator;
@ccclass("SwitchImgSourceGroup")
export class SwitchImgSourceGroup {
@property({ type: cc.Node })
public Sprite: cc.Sprite = null;
@property({ type: cc.SpriteFrame/*, visible: function (this: ImageGroup) { return this.Reset; } */ })
public SourceImg: cc.SpriteFrame[] = [];
public SetImg(obj: cc.Sprite, switchObj: cc.SpriteFrame): void {
if (obj == null || switchObj == null) {
return;
}
obj.getComponent(cc.Sprite).spriteFrame = switchObj;
}
}
@ccclass
export default class SwitchImgGroup extends cc.Component {
@property({ displayName: "換UI群組", type: SwitchImgSourceGroup })
public ImgGroups: SwitchImgSourceGroup[] = [];
public Run(): void {
if (this.ImgGroups != null && this.ImgGroups.length) {
for (let group of this.ImgGroups) {
group.SetImg(group.Sprite, group.SourceImg[ScreenResize.IsPortrait]);
}
}
}
}