Commit adb58335 authored by 范雪寒's avatar 范雪寒

feat: 边界check

parent 1050217c
......@@ -86,7 +86,7 @@ cc.Class({
async getBundleInfoList() {
await this.asyncDelayLog('汪汪汪31');
const jsonStr = this.callNativeFunction({ name: 'loadSceneList', value: '' });
await this.asyncDelayLog('汪汪汪32');
......@@ -111,6 +111,16 @@ cc.Class({
this.currentBundleIndex = index;
const currentBundleInfo = this.bundleInfoList[this.currentBundleIndex];
const btnLeft = this.node.getChildByName('BtnLeft');
const btnRight = this.node.getChildByName('BtnRight');
if (this.currentBundleIndex == 0) {
btnLeft.active = false;
}
if (this.currentBundleIndex == this.bundleInfoList.length - 1) {
btnRight.active = false;
}
this.baseUrl = currentBundleInfo.baseUrl;
this.token = currentBundleInfo.token;
this.homework_id = currentBundleInfo.homework_id;
......@@ -198,20 +208,25 @@ cc.Class({
const btnLeft = this.node.getChildByName('BtnLeft');
btnLeft.on('click', () => {
if (this.currentBundleIndex - 1 < 0) {
this.jumpToBundleByIndex(this.bundleInfoList.length - 1);
} else {
this.jumpToBundleByIndex(this.currentBundleIndex - 1);
return;
}
this.jumpToBundleByIndex(this.currentBundleIndex - 1);
});
const btnRight = this.node.getChildByName('BtnRight');
btnRight.on('click', () => {
if (this.currentBundleIndex + 1 >= this.bundleInfoList.length) {
this.jumpToBundleByIndex(0);
} else {
this.jumpToBundleByIndex(this.currentBundleIndex + 1);
return;
}
this.jumpToBundleByIndex(this.currentBundleIndex + 1);
});
if (this.currentBundleIndex == 0) {
btnLeft.active = false;
}
if (this.currentBundleIndex == this.bundleInfoList.length - 1) {
btnRight.active = false;
}
},
callNativeFunction(param) {
......
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