[add] Engine

This commit is contained in:
2022-08-26 16:48:17 +08:00
parent f67e566f2a
commit d9c19f096c
197 changed files with 10626 additions and 0 deletions

View File

@@ -0,0 +1,35 @@
import ScreenResize from "../ScreenResize";
import { UIManager } from "../UIManager";
const { ccclass, property } = cc._decorator;
@ccclass("SwitchImgSource")
export class SwitchImgSource {
@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 SwitchImgGroupExtra extends cc.Component {
@property({ displayName: "換UI群組", type: SwitchImgSource })
public ImgGroups: SwitchImgSource[] = [];
public Run(): void {
if (this.ImgGroups != null && this.ImgGroups.length) {
for (let group of this.ImgGroups) {
group.SetImg(group.Sprite, group.SourceImg[ScreenResize.IsPortrait]);
}
}
}
onLoad() {
UIManager.DireEvent.AddCallback(this.Run, this);
this.Run();
}
}