This commit is contained in:
dgflash
2024-10-24 15:50:35 +08:00
3 changed files with 33 additions and 27 deletions

View File

@@ -103,7 +103,7 @@ export class LayerManager {
let finalW: number = 0;
let finalH: number = 0;
if (windowAspectRatio > designAspectRatio) {
finalH = drs.height;
finalW = finalH * ws.width / ws.height;
@@ -256,8 +256,13 @@ export class LayerManager {
* @param uiArgs 新打开场景参数
*/
replace(removeUiId: number, openUiId: number, uiArgs: any = null) {
this.open(openUiId, uiArgs);
this.remove(removeUiId);
const callbacks: UICallbacks = {
onAdded: (node: Node, params: any) => {
this.remove(removeUiId);
}
};
this.open(openUiId, uiArgs, callbacks);
}
/**

View File

@@ -23,7 +23,7 @@ export default class ButtonSimple extends Component {
type: AudioClip
})
private effect: AudioClip = null!;
private effectIds: number[] = [];
// private effectIds: number[] = [];
private touchCount = 0;
private touchtEndTime = 0;
@@ -57,10 +57,11 @@ export default class ButtonSimple extends Component {
/** 短按触摸音效 */
protected async playEffect() {
if (this.effect) {
const effectId = await oops.audio.playEffect(this.effect, resLoader.defaultBundleName, () => {
this.effectIds.remove(effectId);
});
if (effectId > 0) this.effectIds.push(effectId);
oops.audio.playEffect(this.effect);
// const effectId = await oops.audio.playEffect(this.effect, resLoader.defaultBundleName, () => {
// this.effectIds.remove(effectId);
// });
// if (effectId > 0) this.effectIds.push(effectId);
}
}
@@ -68,11 +69,10 @@ export default class ButtonSimple extends Component {
this.node.off(Node.EventType.TOUCH_END, this.onTouchEnd, this);
this.node.off(Node.EventType.TOUCH_CANCEL, this.onTouchEnd, this);
if (this.effect) {
this.effectIds.forEach(effectId => {
console.log(effectId);
oops.audio.putEffect(effectId, this.effect);
});
}
// if (this.effect) {
// this.effectIds.forEach(effectId => {
// oops.audio.putEffect(effectId, this.effect);
// });
// }
}
}

View File

@@ -27,7 +27,7 @@ export default class UIButton extends Button {
type: AudioClip
})
private effect: AudioClip = null!;
private effectIds: number[] = [];
// private effectIds: number[] = [];
/** 触摸次数 */
private _touchCount = 0;
@@ -61,19 +61,20 @@ export default class UIButton extends Button {
/** 短按触摸音效 */
protected async playEffect() {
if (this.effect) {
const effectId = await oops.audio.playEffect(this.effect, resLoader.defaultBundleName, () => {
this.effectIds.remove(effectId);
});
if (effectId > 0) this.effectIds.push(effectId);
oops.audio.playEffect(this.effect);
// const effectId = await oops.audio.playEffect(this.effect, resLoader.defaultBundleName, () => {
// this.effectIds.remove(effectId);
// });
// if (effectId > 0) this.effectIds.push(effectId);
}
}
onDestroy() {
if (this.effect) {
this.effectIds.forEach(effectId => {
console.log(effectId);
oops.audio.putEffect(effectId, this.effect);
});
}
}
// onDestroy() {
// if (this.effect) {
// this.effectIds.forEach(effectId => {
// console.log(effectId);
// oops.audio.putEffect(effectId, this.effect);
// });
// }
// }
}