[add] Engine
This commit is contained in:
@@ -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();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user