HarmonyOS鸿蒙Next中横屏游戏时容易误触屏幕底部,造成上划一次就退出游戏
HarmonyOS鸿蒙Next中横屏游戏时容易误触屏幕底部,造成上划一次就退出游戏 有没有API可以控制导航手势,第一次上划只是显示导航条,短时间内第二次上划才会退出?
还有一个疑惑,导航条的作用是什么?为什么从底部上划,导航条还没出现就退出游戏了。
有没有api可以拦截系统导航手势的,我看文档里是组件上手势拦截
更多关于HarmonyOS鸿蒙Next中横屏游戏时容易误触屏幕底部,造成上划一次就退出游戏的实战系列教程也可以访问 https://www.itying.com/category-93-b0.html
是已经使用应用扩展布局隐藏避让区的方案实现沉浸式效果(https://developer.huawei.com/consumer/cn/doc/harmonyos-guides/arkts-develop-apply-immersive-effects#section202484117114),还是有误触退出屏幕么
onWindowStageCreate(windowStage: window.WindowStage): void {
// Main window is created, set main page for this ability
TuanjieLog.info(’%{public}s’, ‘TuanjiePlayerAbility onWindowStageCreate’);
this.windowStage = this.windowStage;
// this.pageUri = ‘pages/TuanjiePlayerAbilityIndex’;
windowStage.loadContent(this.pageUri, (err, data) => {
if (err.code) {
TuanjieLog.error(‘Failed to load the content. Cause: %{public}s’, JSON.stringify(err) ?? ‘’);
return;
}
// set full screen at first
let windowClass = windowStage.getMainWindowSync();
try {
SetToGlobalThis(WindowUtils.MainWindowKey, windowClass);
WindowUtils.setWindowSizeChangeCallback();
WindowUtils.setWindowAvoidAreaChangeCallBack();
windowClass.setWindowLayoutFullScreen(true).then(() => {
console.info(‘Succeeded in setting the window layout to full-screen mode.’);
}).catch((err: BusinessError) => {
console.error(Failed to set the window layout to full-screen mode. Code is ${err.code}, message is ${err.message}
);
});
} catch (err) {
console.error('Failed to obtain the main window. Cause: ’ + JSON.stringify(err));
}
windowClass.setSpecificSystemBarEnabled(‘navigationIndicator’, false).then(() => {
console.info(‘Succeeded in setting the navigation indicator to be invisible.’);
}).catch((err: BusinessError) => {
console.error(Failed to set the navigation indicator to be invisible. Code is ${err.code}, message is ${err.message}
);
});
TuanjieLog.info(‘Succeeded in loading the content. Data: %{public}s’, JSON.stringify(data) ?? ‘’);
});
// set callback
windowStage.on('windowStageEvent', (data) => {
let stageEventType: window.WindowStageEventType = data;
switch (stageEventType) {
case window.WindowStageEventType.ACTIVE:
TuanjieLog.info('windowStage active.');
Tuanjie.nativeOnWindowStageActive();
break;
case window.WindowStageEventType.INACTIVE:
TuanjieLog.info('windowStage inactive.');
Tuanjie.nativeOnWindowStageInActive();
break;
case window.WindowStageEventType.RESUMED:
TuanjieLog.info('windowStage resumed.');
this.onResume();
break;
case window.WindowStageEventType.PAUSED:
TuanjieLog.info('windowStage paused.');
this.onPause();
break;
default:
break;
}
})
}
很喜歡HarmonyOS的卡片式設計,信息一目了然,操作也更便捷。
变成偶尔触发退出了还是没有任何作用?
如果想实现这种效果,那必须得使导航手势失效,可是没找到官方提供的API
https://developer.huawei.com/consumer/cn/doc/design-guides/navigation-0000001957075737#section36002574385
在HarmonyOS鸿蒙Next中,横屏游戏时误触屏幕底部导致退出游戏的问题,可以通过以下方法解决:
- 启用防误触模式:在系统设置中开启“防误触”功能,减少误操作。
- 调整手势灵敏度:在“手势导航”设置中,降低手势灵敏度,避免误触发。
- 使用虚拟导航键:将手势导航切换为虚拟导航键,减少误触概率。
- 游戏模式:部分游戏支持“游戏模式”,开启后可屏蔽部分系统手势。
通过这些设置,可以有效减少误触问题,提升游戏体验。