Commit fe52a851 authored by 李维's avatar 李维

修复背景图过长导致的黑屏

添加背景图切片功能
parent 576030aa
......@@ -108,6 +108,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
this.initHeaderAndFooter(); // 顶部和底部图片
this.initVideoPlayerLayer(); // 视频播放层
await this.initHotZoneBg(); // 初始化背景
this.initSlicedHotZoneBg(); // 切片背景图 - 修复某些设备上背景图过长导致的黑屏
this.initHotZoneItem(); // 初始化热区数据
this.initScorePanel();
this.initActionButton();
......@@ -556,6 +557,34 @@ export default class SceneComponent extends MyCocosSceneComponent {
});
}
initSlicedHotZoneBg() {
if(!this.data.hotZoneBgSliceList || this.data.hotZoneBgSliceList.length == 0 ) {
return
}
const svContentSlicedBg = cc.find("Canvas/MainContent/ScorllView/view/content/slicedBg");
const pAll = [];
this.data.hotZoneBgSliceList.forEach((imgObj, index) => {
pAll.push(new Promise((resovle, reject) =>{
cc.assetManager.loadRemote(imgObj.image_url, (err, img) => {
resovle(img);
});
}))
});
Promise.all(pAll).then(res=>{
res.forEach((img, index)=>{
// 创建节点 挂载背景图
const sprNode = new cc.Node();
sprNode.name = "sliced_" + index;
var sf = new cc.SpriteFrame(img);
const spr = sprNode.addComponent(cc.Sprite);
spr.spriteFrame = sf;
svContentSlicedBg.addChild(sprNode)
})
})
}
picNodeArr = [];
scoreValidater = [];
// 根据配置的内容类型 生成对应的题型
......@@ -3080,6 +3109,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
this.disableScroll(); // 禁用页面滚动
await this.initHotZoneBg();
this.initSlicedHotZoneBg(); // 切片背景图 - 修复某些设备上背景图过长导致的黑屏
this.initHotZoneItem();
this.initScorePanel();
this.enableScroll(); // 启用页面滚动
......
This diff is collapsed.
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -39,6 +39,19 @@
>
</app-custom-hot-zone>
<h2 style="margin-top: 10px;">热区背景图切片:</h2>
<div style="font-size: 16px; border: 2px solid #ccc; border-radius: 10px; padding: 10px 150px 10px 10px;">
<div style="display: flex;">
<div *ngFor="let it of item.hotZoneBgSliceList; let i = index" style="width: 200px;">
<app-upload-image-with-preview
[picUrl]="it.image_url"
(imageUploaded)="onImageUploadSuccess($event, 'image_url', it)">
</app-upload-image-with-preview>
</div>
</div>
<button nz-button (click)="addBgImageSlice();"><i nz-icon nzType="plus-circle"></i>创建</button>
</div>
<h2 style="margin-top: 10px;">快速创建热区:</h2>
<div style="font-size: 16px; border: 2px solid #ccc; border-radius: 10px; padding: 10px 150px 10px 10px;">
<input type="text" nz-input [(ngModel)]="fastHotZoneStr"/>
......
......@@ -121,6 +121,17 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy, AfterViewIni
this.nzMessageService.success('创建成功,需要保存热区');
}
// 添加背景图切片
addBgImageSlice() {
if(!this.item.hotZoneBgSliceList) {
this.item.hotZoneBgSliceList = [];
}
this.item.hotZoneBgSliceList.push({
image_url: ""
})
this.save()
}
// 添加热区配置
addHotZoneConfig() {
if(!this.item.hotZoneConfigArr) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment