问题
我正在使用HTML5 Canvas创建游戏,游戏有一个主菜单,主菜单有多个按钮供您选择.我发现如果用户按下"播放"按钮来显示游戏,我会很困难和困惑.这是主菜单的图像:
问题
问题是如何在游戏中从这个页面到另一个页面?
我想你应该已经明白了.我故意使用画布创建了菜单,我知道我可以使用HTML制作菜单,但我不能因为这是Canvas可以做什么,有什么好坏等等的学生的例子.
代码
<html>
<head>
<title>Sean Coyne</title>
</head>
<body onload="start_game()">
<body>
<div style id="canvas">
<canvas id="myCanvas" style="border:5px solid #410b11" height="320" width="480">
<p>Your browser does not support HTML5!</p>
</canvas>
<script type="text/javascript">
//Referencing the canvas
var canvas = document.getElementById("myCanvas");
var context = canvas.getContext("2d");
var width = canvas.getAttribute('width');
var height = canvas.getAttribute('height');
//Finding the position of the mouse
var mouseX;
var mouseY;
//Images
var bgImage = new Image();
var logoImage = new Image();
var playImage = new Image();
var …Run Code Online (Sandbox Code Playgroud)