Hi all.
I created a new project in cocos2d-js-v3.6.1 and I wish my game has exact size that the canvas tag in the html page. But the game always has full size of my display (2560 x 1440).
Only one thing helped me - cc.view.setViewPortInPoints(). In this function I can pass size which I want, but I should also pass position of the viewport. But I need to position my canvas as it is - as it has been defined in the html page.
Another problem of setViewPortInPoints is that this function manipulates with coordinates in design resolution space. For example, if I set design resolution to 800 x 600, then viewport configured so:
cc.view.setViewPortInPoints(0, 0, 800, 600)
will fit all screen. But I want to operate in browser’s original coordinate space.
So is there any way to use canvas as it described in the html page ? I wish to have my page look like a simple web site with some elements and my game, but all should be aligned and positioned as it described in HTML and CSS stylesheets. I don’t wish to have any changes in the page elements (including the canvas) made by the engine: no changes in size, no changes in position. Is it possible with cocos2d?