本帖最後由 kim 於 2012-9-6 22:34 編輯 # @7 m3 z$ ]0 U* O% v
- <!DOCTYPE html>
- <head>
- <meta charset="utf-8">
- </head>
- <body>
- <div id="gameArea"><canvas id="gameCanvas"></canvas></div>
- <script>
- var gameHeight = window.innerHeight;
- var gameWidth = window.innerWidth;
-
- var gameArea = document.getElementById("gameArea");
- var gameCanvas = document.getElementById("gameCanvas");
-
- gameArea.style.height = gameHeight;
- gameArea.style.width = gameWidth;
- gameCanvas.height = gameHeight;
- gameCanvas.width = gameWidth;
-
- var ctx = gameCanvas.getContext("2d");
- ctx.fillStyle = "rgb(0,20,0)";
- ctx.fillRect(0,0,gameWidth,gameHeight);
- </script>
- </body>
複製代碼 老師為甚麼我執行時都沒有出現顏色阿 |