init
This commit is contained in:
@@ -0,0 +1,69 @@
|
||||
import { _decorator, isValid, Label, Node, Sprite, UITransform, view } from 'cc';
|
||||
import Utils from '../../Main/Common/Utils';
|
||||
import { InnerMsgCode } from '../../Main/Config/InnerMsgCode';
|
||||
import li_BaseView from '../../Main/Common/li_BaseView';
|
||||
import ResManager from '../../Main/Manager/ResManager';
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
//场景背景层
|
||||
@ccclass('SceneBgLayer')
|
||||
export class SceneBgLayer extends li_BaseView {
|
||||
private _nodeTab: any = {};
|
||||
private _data;
|
||||
|
||||
private sceneBg: Sprite = null;
|
||||
private sceneRole: Sprite = null;
|
||||
|
||||
//----重写父类接口---------------------------------------
|
||||
onLoadCT() {
|
||||
this.registerListenner();
|
||||
Utils.parseNode(this.node, this._nodeTab)
|
||||
this.sceneBg = this._nodeTab.sceneBg.getComponent(Sprite)!;
|
||||
this.sceneRole = this._nodeTab.sceneRole.getComponent(Sprite)!;
|
||||
}
|
||||
openUIDataCT(data: any): void {
|
||||
this._data = data
|
||||
}
|
||||
|
||||
|
||||
registerListenner() {
|
||||
Utils.addInnerEL(InnerMsgCode.SceneLayerBgUp, this, this.resiveBgUp)
|
||||
}
|
||||
|
||||
|
||||
start() {
|
||||
|
||||
}
|
||||
|
||||
update(deltaTime: number) {
|
||||
|
||||
}
|
||||
|
||||
//刷新场景背景消息
|
||||
resiveBgUp(data) {
|
||||
if (data) {
|
||||
this.refreshBg(data.bgPath, data.rolePath)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//刷新背景图,npc肖像
|
||||
refreshBg(bgPath:string, rolePath:string) {
|
||||
//背景图
|
||||
if (isValid(this.sceneBg)) {
|
||||
let path = `bg/${bgPath}`
|
||||
ResManager.I.changeBundleSpriteFrame(this.sceneBg, path, "Raw", ()=>{
|
||||
//调整背景图适配
|
||||
Utils.adjustBgPixelRatio(this.sceneBg.node, 1)
|
||||
})
|
||||
}
|
||||
//npc肖像
|
||||
if (isValid(this.sceneRole)) {
|
||||
let path = `role/${rolePath}`
|
||||
ResManager.I.changeBundleSpriteFrame(this.sceneRole, path, "Raw")
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user