From 0d6bf3263bb25e8767a28f474025283a6c5ba640 Mon Sep 17 00:00:00 2001 From: pandamicro Date: Sun, 1 Nov 2015 18:33:05 +0800 Subject: [PATCH] Improve js templates with noCache and cc.view.setRealPixelResolution docs --- templates/js-template-default/main.js | 11 +++++++++-- templates/js-template-default/project.json | 1 + templates/js-template-runtime/main.js | 11 +++++++++-- templates/js-template-runtime/project.json | 1 + tests/js-tests/project.json | 1 + web | 2 +- 6 files changed, 22 insertions(+), 5 deletions(-) diff --git a/templates/js-template-default/main.js b/templates/js-template-default/main.js index 95f14b8224..56bfaaadc4 100644 --- a/templates/js-template-default/main.js +++ b/templates/js-template-default/main.js @@ -22,6 +22,10 @@ "frameRate" : 60, // "frameRate" set the wanted frame rate for your game, but the real fps depends on your game implementation and the running environment. + "noCache" : false, + // Set "noCache" to true can make the loader ignoring the html page cache while loading your resources, + // especially useful in Android web browsers. + "id" : "gameCanvas", // "gameCanvas" sets the id of your canvas element on the web page, it's useful only on web. @@ -51,12 +55,15 @@ cc.game.onStart = function(){ if(!cc.sys.isNative && document.getElementById("cocosLoading")) //If referenced loading.js, please remove it document.body.removeChild(document.getElementById("cocosLoading")); - // Pass true to enable retina display, disabled by default to improve performance - cc.view.enableRetina(false); + // Pass true to enable retina display, on Android disabled by default to improve performance + cc.view.enableRetina(cc.sys.os === cc.sys.OS_IOS ? true : false); // Adjust viewport meta cc.view.adjustViewPort(true); // Setup the resolution policy and design resolution size cc.view.setDesignResolutionSize(800, 450, cc.ResolutionPolicy.SHOW_ALL); + // Instead of set design resolution, you can also set the real pixel resolution size + // Uncomment the following line and delete the previous line. + // cc.view.setRealPixelResolution(960, 640, cc.ResolutionPolicy.SHOW_ALL); // The game will be resized when browser size change cc.view.resizeWithBrowserSize(true); //load resources diff --git a/templates/js-template-default/project.json b/templates/js-template-default/project.json index e54f870660..b407e81b0d 100644 --- a/templates/js-template-default/project.json +++ b/templates/js-template-default/project.json @@ -4,6 +4,7 @@ "debugMode" : 1, "showFPS" : true, "frameRate" : 60, + "noCache" : false, "id" : "gameCanvas", "renderMode" : 0, "engineDir":"frameworks/cocos2d-html5", diff --git a/templates/js-template-runtime/main.js b/templates/js-template-runtime/main.js index b2dcd6904f..0cff41c312 100644 --- a/templates/js-template-runtime/main.js +++ b/templates/js-template-runtime/main.js @@ -22,6 +22,10 @@ "frameRate" : 60, // "frameRate" set the wanted frame rate for your game, but the real fps depends on your game implementation and the running environment. + "noCache" : false, + // Set "noCache" to true can make the loader ignoring the html page cache while loading your resources, + // especially useful in Android web browsers. + "id" : "gameCanvas", // "gameCanvas" sets the id of your canvas element on the web page, it's useful only on web. @@ -51,12 +55,15 @@ cc.game.onStart = function(){ if(!cc.sys.isNative && document.getElementById("cocosLoading")) //If referenced loading.js, please remove it document.body.removeChild(document.getElementById("cocosLoading")); - // Pass true to enable retina display, disabled by default to improve performance - cc.view.enableRetina(false); + // Pass true to enable retina display, on Android disabled by default to improve performance + cc.view.enableRetina(cc.sys.os === cc.sys.OS_IOS ? true : false); // Adjust viewport meta cc.view.adjustViewPort(true); // Setup the resolution policy and design resolution size cc.view.setDesignResolutionSize(960, 640, cc.ResolutionPolicy.SHOW_ALL); + // Instead of set design resolution, you can also set the real pixel resolution size + // Uncomment the following line and delete the previous line. + // cc.view.setRealPixelResolution(960, 640, cc.ResolutionPolicy.SHOW_ALL); // The game will be resized when browser size change cc.view.resizeWithBrowserSize(true); //load resources diff --git a/templates/js-template-runtime/project.json b/templates/js-template-runtime/project.json index e54f870660..b407e81b0d 100644 --- a/templates/js-template-runtime/project.json +++ b/templates/js-template-runtime/project.json @@ -4,6 +4,7 @@ "debugMode" : 1, "showFPS" : true, "frameRate" : 60, + "noCache" : false, "id" : "gameCanvas", "renderMode" : 0, "engineDir":"frameworks/cocos2d-html5", diff --git a/tests/js-tests/project.json b/tests/js-tests/project.json index 249f59d5d7..33dec07096 100644 --- a/tests/js-tests/project.json +++ b/tests/js-tests/project.json @@ -2,6 +2,7 @@ "debugMode" : 1, "showFPS" : true, "frameRate" : 60, + "noCache" : false, "id" : "gameCanvas", "renderMode" : 0, "engineDir" : "../../web/", diff --git a/web b/web index c0242a98fb..8737f56bda 160000 --- a/web +++ b/web @@ -1 +1 @@ -Subproject commit c0242a98fb49681b053438a55f8eb15e56682b5d +Subproject commit 8737f56bda7e73233ecca06369134bc83c4fa008