Files
18xchat/.svn/pristine/45/45b961ee39b4ae379d276ed9a499f00616f88933.svn-base
T
2025-07-17 17:18:21 +08:00

70 lines
1.8 KiB
Plaintext

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 = `Zjm/${bgPath}`
ResManager.I.changeBundleSpriteFrame(this.sceneBg, path, "Raw", ()=>{
//调整背景图适配
Utils.adjustBgPixelRatio(this.sceneBg.node, 1)
})
}
//npc肖像
if (isValid(this.sceneRole)) {
let path = `Zjm/${rolePath}`
ResManager.I.changeBundleSpriteFrame(this.sceneRole, path, "Raw")
}
}
}