Rem*_*miX 2 javascript html5 canvas cocos2d-iphone cocos2d-html5
我是Cocos2D-HTML5(和HTML5本身)的新手,我试图让画布成为页面的完整大小.我对在互联网上记录的问题很少感到困惑,所以我希望它真的很简单.
问题是<canvas>元素不接受width="100%"或height="100%"只接受像素(但是它不会拉伸以适合窗口).
我也尝试了这里描述的解决方案(css以及javascript),但似乎Cocos2D调整画布大小以适应width和height属性,如果省略,使用默认大小300 x 150 px(没有Cocos2D我得到整页画布).
如何更改画布大小以适合Cocos2D本身的页面?
Vix*_*inG 13
<canvas id="canvas"></canvas>
Run Code Online (Sandbox Code Playgroud)
var canvas = document.getElementById('canvas'),
context = canvas.getContext('2d');
canvas.width = window.innerWidth;
canvas.height = window.innerHeight;
Run Code Online (Sandbox Code Playgroud)
* { margin:0; padding:0; } /* to remove the top and left whitespace */
html, body { width:100%; height:100%; } /* just to be sure these are full screen*/
canvas { display:block; } /* To remove the scrollbars */
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
12599 次 |
| 最近记录: |