feat: 适配关卡内图片的圆角
This commit is contained in:
@@ -743,8 +743,8 @@
|
||||
},
|
||||
"_lpos": {
|
||||
"__type__": "cc.Vec3",
|
||||
"x": 8.006,
|
||||
"y": 2.227,
|
||||
"x": -4.854,
|
||||
"y": -3.284,
|
||||
"z": 0
|
||||
},
|
||||
"_lrot": {
|
||||
@@ -756,9 +756,9 @@
|
||||
},
|
||||
"_lscale": {
|
||||
"__type__": "cc.Vec3",
|
||||
"x": 1.0000000000000002,
|
||||
"y": 1.0000000000000002,
|
||||
"z": 0.759
|
||||
"x": 0.92,
|
||||
"y": 0.92,
|
||||
"z": 0.698
|
||||
},
|
||||
"_mobility": 0,
|
||||
"_layer": 1073741824,
|
||||
@@ -1051,7 +1051,7 @@
|
||||
"node": {
|
||||
"__id__": 25
|
||||
},
|
||||
"_enabled": true,
|
||||
"_enabled": false,
|
||||
"__prefab": {
|
||||
"__id__": 41
|
||||
},
|
||||
@@ -1069,7 +1069,7 @@
|
||||
"__uuid__": "02687761-81ab-42cb-b552-0db291d9ddd5@f9941",
|
||||
"__expectedType__": "cc.SpriteFrame"
|
||||
},
|
||||
"_type": 0,
|
||||
"_type": 1,
|
||||
"_fillType": 0,
|
||||
"_sizeMode": 0,
|
||||
"_fillCenter": {
|
||||
@@ -1318,7 +1318,7 @@
|
||||
"_lpos": {
|
||||
"__type__": "cc.Vec3",
|
||||
"x": 0,
|
||||
"y": -5.11,
|
||||
"y": 0.401,
|
||||
"z": 0
|
||||
},
|
||||
"_lrot": {
|
||||
@@ -1330,9 +1330,9 @@
|
||||
},
|
||||
"_lscale": {
|
||||
"__type__": "cc.Vec3",
|
||||
"x": 1.0000000000000002,
|
||||
"y": 1.0000000000000002,
|
||||
"z": 0.759
|
||||
"x": 0.92,
|
||||
"y": 0.92,
|
||||
"z": 0.698
|
||||
},
|
||||
"_mobility": 0,
|
||||
"_layer": 1073741824,
|
||||
@@ -1625,7 +1625,7 @@
|
||||
"node": {
|
||||
"__id__": 49
|
||||
},
|
||||
"_enabled": true,
|
||||
"_enabled": false,
|
||||
"__prefab": {
|
||||
"__id__": 65
|
||||
},
|
||||
@@ -1643,7 +1643,7 @@
|
||||
"__uuid__": "02687761-81ab-42cb-b552-0db291d9ddd5@f9941",
|
||||
"__expectedType__": "cc.SpriteFrame"
|
||||
},
|
||||
"_type": 0,
|
||||
"_type": 1,
|
||||
"_fillType": 0,
|
||||
"_sizeMode": 0,
|
||||
"_fillCenter": {
|
||||
@@ -7939,7 +7939,6 @@
|
||||
"titleLevelLabel": {
|
||||
"__id__": 14
|
||||
},
|
||||
"currentLevelIndex": 0,
|
||||
"clickAudio": {
|
||||
"__uuid__": "a68a6314-fb7c-48a9-bd6c-0a65ef665d50",
|
||||
"__expectedType__": "cc.AudioClip"
|
||||
@@ -7964,6 +7963,11 @@
|
||||
"__uuid__": "e41c722f-f605-47f7-9ce4-abff0ed2020f",
|
||||
"__expectedType__": "cc.Prefab"
|
||||
},
|
||||
"roundedSpriteEffect": {
|
||||
"__uuid__": "f0080a34-1786-4547-8d81-d89cc517b63e",
|
||||
"__expectedType__": "cc.EffectAsset"
|
||||
},
|
||||
"mainImageCornerRadius": 0.1,
|
||||
"_id": ""
|
||||
},
|
||||
{
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { _decorator, Node, EditBox, instantiate, Vec3, Button, Label, Sprite, SpriteFrame, AudioClip, AudioSource, Prefab } from 'cc';
|
||||
import { _decorator, Node, EditBox, instantiate, Vec3, Button, Label, Sprite, SpriteFrame, AudioClip, AudioSource, Prefab, EffectAsset, UITransform } from 'cc';
|
||||
import { BaseView } from 'db://assets/scripts/core/BaseView';
|
||||
import { ViewManager } from 'db://assets/scripts/core/ViewManager';
|
||||
import { StaminaManager } from 'db://assets/scripts/utils/StaminaManager';
|
||||
@@ -13,6 +13,7 @@ import { WrongModal } from 'db://assets/prefabs/WrongModal';
|
||||
import { TimeoutModal } from 'db://assets/prefabs/TimeoutModal';
|
||||
import { StaminaInfo, NextLevelData } from 'db://assets/scripts/types/ApiTypes';
|
||||
import { AchievementTitleManager } from 'db://assets/scripts/utils/AchievementTitleManager';
|
||||
import { applyRoundedCorner } from 'db://assets/scripts/utils/roundedMaterial.utils';
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
/**
|
||||
@@ -37,6 +38,9 @@ export class PageLevel extends BaseView {
|
||||
/** 答案正确后展示包袱答案的停留时间 */
|
||||
private static readonly PASS_MODAL_DELAY_MS = 2000;
|
||||
|
||||
/** 图片2描述默认文案 */
|
||||
private static readonly DEFAULT_IMAGE2_DESCRIPTION = '这是什么?';
|
||||
|
||||
// ========== 节点引用 ==========
|
||||
@property(Node)
|
||||
inputLayout: Node | null = null;
|
||||
@@ -116,6 +120,14 @@ export class PageLevel extends BaseView {
|
||||
@property(Prefab)
|
||||
timeoutModalPrefab: Prefab | null = null;
|
||||
|
||||
/** 主图圆角材质 EffectAsset */
|
||||
@property(EffectAsset)
|
||||
roundedSpriteEffect: EffectAsset | null = null;
|
||||
|
||||
/** 主图圆角半径比例(相对于短边,0-0.5) */
|
||||
@property
|
||||
mainImageCornerRadius: number = 0.1;
|
||||
|
||||
// ========== 内部状态 ==========
|
||||
/** 当前创建的输入框节点数组 */
|
||||
private _inputNodes: Node[] = [];
|
||||
@@ -814,6 +826,7 @@ export class PageLevel extends BaseView {
|
||||
const sprite = this.mainImage.getComponent(Sprite);
|
||||
if (sprite && spriteFrame) {
|
||||
sprite.spriteFrame = spriteFrame;
|
||||
this.applyMainImageRoundedCorner(sprite);
|
||||
console.log('[PageLevel] 设置主图1');
|
||||
}
|
||||
}
|
||||
@@ -827,10 +840,30 @@ export class PageLevel extends BaseView {
|
||||
const sprite = this.mainImage2.getComponent(Sprite);
|
||||
if (sprite && spriteFrame) {
|
||||
sprite.spriteFrame = spriteFrame;
|
||||
this.applyMainImageRoundedCorner(sprite);
|
||||
console.log('[PageLevel] 设置主图2');
|
||||
}
|
||||
}
|
||||
|
||||
private applyMainImageRoundedCorner(sprite: Sprite): void {
|
||||
if (!this.roundedSpriteEffect) {
|
||||
return;
|
||||
}
|
||||
|
||||
const uiTransform = sprite.node.getComponent(UITransform);
|
||||
if (!uiTransform) {
|
||||
return;
|
||||
}
|
||||
|
||||
applyRoundedCorner(
|
||||
sprite,
|
||||
this.roundedSpriteEffect,
|
||||
uiTransform.width,
|
||||
uiTransform.height,
|
||||
this.mainImageCornerRadius
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置图片描述文本
|
||||
*/
|
||||
@@ -839,7 +872,7 @@ export class PageLevel extends BaseView {
|
||||
this.image1DescLabel.string = desc1 ?? '';
|
||||
}
|
||||
if (this.image2DescLabel) {
|
||||
this.image2DescLabel.string = desc2 ?? '';
|
||||
this.image2DescLabel.string = desc2?.trim() ? desc2 : PageLevel.DEFAULT_IMAGE2_DESCRIPTION;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -546,7 +546,7 @@
|
||||
},
|
||||
"_contentSize": {
|
||||
"__type__": "cc.Size",
|
||||
"width": 1297,
|
||||
"width": 1299,
|
||||
"height": 1004
|
||||
},
|
||||
"_anchorPoint": {
|
||||
@@ -583,7 +583,7 @@
|
||||
"a": 255
|
||||
},
|
||||
"_spriteFrame": {
|
||||
"__uuid__": "3ef3f86f-bc1f-49b7-a50f-0e8683cd2400@f9941",
|
||||
"__uuid__": "f8c208df-8e8c-456e-9f97-1d1c07518452@f9941",
|
||||
"__expectedType__": "cc.SpriteFrame"
|
||||
},
|
||||
"_type": 0,
|
||||
|
||||
Reference in New Issue
Block a user