let dialogue1 ="哈喽,还记得你的童年是什么样子的嘛?" let dialogue2 = "童年所经历的一切,都会在时光里发酵成甜蜜的回忆。" let…
- User
let dialogue1 ="哈喽,还记得你的童年是什么样子的嘛?" let dialogue2 = "童年所经历的一切,都会在时光里发酵成甜蜜的回忆。" let dialogue3 = "几岁时的一棵树一株草一片天一条街,或许就是你心灵的栖息地和灵魂的中转站。" let dialogue4 = "希望你的一生都可以被童年治愈。" let dialogue5 = "那么请你来说几个可以准确描述你童年记忆的关键词吧~" let dialogue6 = "通关成功,接下来我们进入下一个主题房间。" let T1 = -1; let T2 = -1; let T3 = 0; let T4 = 0; let T5 = 0; let T6 = 0; let showImgClick = false; // 点击开关 let showSecondText = true; // 新增变量控制第二段文字是否显示过 function scene1() { background(0); image(img1, width / 2, height / 2);//场景背景1
if (showImage1) {//左右键控制的变量,具体控制小人运动 if (isMoving) { animateZoulu(); let nextX = cRen.x + vRen.x; if (nextX >= 250 && nextX <= 1670) {//限制小人不走出画外 cRen.x = nextX; } } image(zoulu[img7FrameIndex], cRen.x, cRen.y); } else if (showImage2) { if (isMoving) { animateZoulu2(); let nextX = cRen.x + vRen2.x; if (nextX >= 250 && nextX <= 1670) { cRen.x = nextX; } } image(zoulu2[img7FrameIndex], cRen.x, cRen.y);//一直到这里,作用同上 } if (showImage3) { text(currentText, width / 2, height * 0.8);//墙上提示词,不按时 }else if(showImage4){ image(img2, width / 2, height / 2); text(text2, width / 2, height * 0.8);//放大图,和缩小提示词 } if (showImg8) { //激活显示图片的开关 image(img8, width / 2, height / 2); } img7X = cRen.x; img7Y = cRen.y;//有关小人走路的变量,不动
fill(255); text(text3, 1720, 350);//门上提示词
//对白字幕 if (T1 === 0 && showSecondText){ T2 = 420; showSecondText = false; // 第二段文字只出现一次 } else if (T1 > 0) { textFont("Simsun"); textSize(35); text(dialogue1,width * 0.5, height * 0.7); T1--; } else if (T2 > 0) { textFont("Simsun"); textSize(35); text(dialogue2, width * 0.5, height * 0.7); T2--; if (T2 === 0){ T3 = 540; } } else if (T3 > 0) { textFont("Simsun"); textSize(35); text(dialogue3, width * 0.5, height * 0.7); T3--; if (T3 === 0){ T4 = 420; } } else if (T4 > 0) { textFont("Simsun"); textSize(35); text(dialogue4, width * 0.5, height * 0.7); T4--; if (T4 === 0){ T5 = 420; } } else if (T5 > 0) { textFont("Simsun"); textSize(35); text(dialogue5, width * 0.5, height * 0.7); T5--; if (T5 === 0){ T6 = 480; } } else if (T6 >0) { textFont("Simsun"); textSize(35); text(dialogue6, width * 0.5, height * 0.7); T6--; } } //对话框出现与否 function mouseClicked() { showImg8 = !showImg8;// 每次点击开关状态取反 } //字幕出现的时长 function mousePressed(){ if (T1 === -1) { textIndex = 0; textLoading = true; T1 = 420; } else if (T1 === 0) { T2 = 420; } else if (T2 === -1){ T3 = 540; } }帮我完善这段p5.js代码,使得从第一段话"哈喽,还记得你的童年是什么样子的嘛?" 只在鼠标第单数次单击时显示,第双数次时不显示。
- Assistant
function mouseClicked() { if (mouseClicks % 2 === 0) { T1 = -1; // 双数次点击不显示对话框 } else { if (T1 === -1) { textIndex = 0; textLoading = true; T1 = 420; // 单数次点击显示对话框 } } mouseClicks++; // 点击次数加1 }