feat:完善 pk 创作关卡
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { _decorator, Node, Button, Sprite, Label, Toggle, ScrollView, EditBox, instantiate, UITransform, Vec2, EventTouch, EffectAsset } from 'cc';
|
||||
import { _decorator, Node, Button, Sprite, Label, Toggle, ScrollView, EditBox, instantiate, UITransform, Vec2, EventTouch, EffectAsset, AudioClip, AudioSource } from 'cc';
|
||||
import { BaseView } from 'db://assets/scripts/core/BaseView';
|
||||
import { ViewManager } from 'db://assets/scripts/core/ViewManager';
|
||||
import { CompletedLevelsManager } from 'db://assets/scripts/utils/CompletedLevelsManager';
|
||||
@@ -69,6 +69,9 @@ export class PageWriteLevels extends BaseView {
|
||||
@property({ tooltip: '关卡封面圆角半径比例(相对于短边,0-0.5)' })
|
||||
coverCornerRadius: number = 0.1;
|
||||
|
||||
@property({ type: AudioClip, tooltip: '关卡项选中/取消选中音效' })
|
||||
itemToggleAudio: AudioClip | null = null;
|
||||
|
||||
private _selectedIndices: Set<number> = new Set();
|
||||
private _levels: CompletedLevel[] = [];
|
||||
private _levelCount: number = 0;
|
||||
@@ -425,6 +428,8 @@ export class PageWriteLevels extends BaseView {
|
||||
this._selectedIndices.delete(index);
|
||||
}
|
||||
|
||||
this._playSound(this.itemToggleAudio);
|
||||
|
||||
console.log('[PageWriteLevels] item切换选中:', index, selected, '当前已选:', this._selectedIndices.size);
|
||||
|
||||
const item = this._itemNodes[index];
|
||||
@@ -507,6 +512,15 @@ export class PageWriteLevels extends BaseView {
|
||||
return true;
|
||||
}
|
||||
|
||||
private _playSound(clip: AudioClip | null): void {
|
||||
if (!clip) {
|
||||
return;
|
||||
}
|
||||
|
||||
const audioSource = this.node.getComponent(AudioSource) ?? this.node.addComponent(AudioSource);
|
||||
audioSource?.playOneShot(clip);
|
||||
}
|
||||
|
||||
private _onPreviewClick(): void {
|
||||
if (!this._validateSelection()) return;
|
||||
const shareTitle = this.shareTitleEditBox?.getComponent(EditBox)?.string?.trim() || '';
|
||||
|
||||
Reference in New Issue
Block a user