Open breathxue opened 10 years ago
Hi,
Please call cc.EGLView.getInstance()._adjustSizeKeepCanvasSize(1000, 800).
hi
I think it is no result. My code like this:
index.html:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Cocos2d-html5 Hello World test</title>
<link rel="icon" type="image/GIF" href="res/favicon.ico"/>
</head>
<body style="padding:0; margin: 0; background: #ff0000;">
<canvas id="gameCanvas" width="800" height="450"></canvas>
<script src="cocos2d.js"></script>
</body>
</html>
main.js
var cocos2dApp = cc.Application.extend({
config: document['ccConfig'],
ctor: function (scene) {
this._super();
this.startScene = scene;
cc.COCOS2D_DEBUG = this.config['COCOS2D_DEBUG'];
cc.initDebugSetting();
cc.setup(this.config['tag']);
cc.AppController.shareAppController().didFinishLaunchingWithOptions();
},
applicationDidFinishLaunching: function () {
// initialize director
var director = cc.Director.getInstance();
cc.EGLView.getInstance()._adjustSizeKeepCanvasSize(2000, 800);
// turn on display FPS
director.setDisplayStats(this.config['showFPS']);
// set FPS. the default value is 1.0/60 if you don't call this
director.setAnimationInterval(1.0 / this.config['frameRate']);
//load resources
cc.LoaderScene.preload(g_resources, function () {
director.replaceScene(new this.startScene());
}, this);
return true;
I think I know how to do it:
var targetSize = cc.size(800, 450);
cc.EGLView.getInstance()._frameSize = targetSize;
var result = cc.EGLView.getInstance()._rpShowAll.apply(cc.EGLView.getInstance(), targetSize);
cc.EGLView.getInstance()._setScaleXYForRenderTexture();
In Html5 the canvas setting is
But I want to exlarge it in code
cc.canvas.width = 1000 cc.canvas.height = 800;
how to do it
I think I know how to do it: