I am running my game on web.
According to the documentation if I set the framesize using cc.view.setFrameSize
On native, it sets the frame size of view.
On web, it sets the size of the canvas’s outer DOM element.
So I expected it to change the size of “Cocos2dGameContainer”
But it has no effect on the size.
When I start the page width and height of “Cocos2dGameContainer” and the “GameCanvas” both get set to 1px automatically.
And it remain that way even though I called setFrameSize
But if I call cc.view.getFrameSize() it return the values I set. But on page the sizes are not changed.
Following shows what is in the web-page. You can see all vales are 1px.
<div id="Cocos2dGameContainer" style="transform: rotate(0deg);
transform-origin: 0px 0px 0px; width: 1px; height: 1px; margin: 0px; padding: 0px; display: block;">
<canvas id="GameCanvas" oncontextmenu="event.preventDefault()" tabindex="99" class="gameCanvas"
width="1" height="1" style="width: 1px; height: 1px; margin-top: 0px; margin-left: 0px;">
</canvas>
</div>
After calling setFrameSize do I have to trigger a redraw ?
How do I change the size ?
Can someone provide some help on this?
I don’t have any header or body tags in my page since the game is embedded in another page.
Can this be the reason for this?
My page looks like this;
<div id="main" class="content" >
<canvas id="GameCanvas" oncontextmenu="event.preventDefault()" tabindex="0" ></canvas>
</div>
But if I add a another div tag containing these 2 elements, And problematically set its size. The size started get set (without calling setFrameSize);
<div id="main" class="content" >
<div id="canvasHolder">
<canvas id="GameCanvas" oncontextmenu="event.preventDefault()" tabindex="0" ></canvas>
<div>
</div>
I set the size using;
var holder = document.getElementById('canvasHolder');
holder.style.width = (devWidth) + 'px';
holder.style.height = (devHeight) + 'px';
Can anyone provide an explanation?