0
我正在制作一本插图故事书,用户点击以阅读故事的下一部分。我做了三个不同的场景(三个不同的页面)。我可以使用eventListener从场景一切换到场景二,但我无法从场景二切换到场景三。HTML5游戏开发
我希望能够在
场景之间切换。当用户点击鼠标:
- 如果当前场景是第一位的,转到第二
- 如果当前场景是第二个,到第三
- 如果当前场景是第三个,回去第一
但我不知道该怎么做。任何帮助表示赞赏。谢谢!
我还应该提到我正在学习基础知识,以便我可以继续进行游戏开发。所以这是一个非常基本的代码。
这里是我的代码:
var c = document.querySelector("#c");
var ctx = c.getContext("2d");
var x = document.getElementById("c");
//Scene One
function sceneOne(){
ctx.fillStyle = "rgb(235,247,255)";
ctx.fillRect(0,0,750,750);
ctx.fillStyle = "rgb(0, 85, 255)";
ctx.font = "70px Impact";
ctx.fillText("The Story of Winston", 40, 130);
};
//Scene Two
function sceneTwo() {
ctx.fillStyle = "rgb(173,239,255)";
ctx.fillRect(0,0,750,750);
ctx.fillStyle="rgb(7, 14, 145)";
ctx.fillText("Lil Winston is born!", 10, 100);
};
//Scee Three
function sceneThree() {
ctx.fillStyle = "rgb(173,239,255)";
ctx.fillRect(0,0,750,750);
ctx.fillStyle = "rgb(7, 14, 145)";
ctx.fillText("Winston grows up!", 10, 100);
};
//Calling scene one
sceneOne();