Merge pull request #14565 from pandamicro/v3

Add js test case for fix, improve template
This commit is contained in:
pandamicro 2015-12-03 18:48:34 +08:00
commit c304348c34
8 changed files with 144 additions and 8 deletions

View File

@ -2868,7 +2868,7 @@ bool js_BezierActions_initWithDuration(JSContext *cx, uint32_t argc, jsval *vp)
if (argc == 2) { if (argc == 2) {
double arg0; double arg0;
cocos2d::_ccBezierConfig arg1; cocos2d::_ccBezierConfig arg1;
ok &= JS::ToNumber( cx, JS::RootedValue(cx, args.get(0)), &arg0); ok &= JS::ToNumber( cx, args.get(0), &arg0);
int num; int num;
cocos2d::Vec2 *arr; cocos2d::Vec2 *arr;

View File

@ -4,7 +4,7 @@
<meta charset="utf-8"> <meta charset="utf-8">
<title>Cocos2d-html5 Hello World test</title> <title>Cocos2d-html5 Hello World test</title>
<link rel="icon" type="image/GIF" href="res/favicon.ico"/> <link rel="icon" type="image/GIF" href="res/favicon.ico"/>
<meta name="viewport" content="width=480, initial-scale=1"> <meta name="viewport" content="initial-scale=1">
<meta name="apple-mobile-web-app-capable" content="yes"/> <meta name="apple-mobile-web-app-capable" content="yes"/>
<meta name="full-screen" content="yes"/> <meta name="full-screen" content="yes"/>
<meta name="screen-orientation" content="portrait"/> <meta name="screen-orientation" content="portrait"/>
@ -23,6 +23,23 @@
<body style="padding:0; margin: 0; background: #000;"> <body style="padding:0; margin: 0; background: #000;">
<script src="res/loading.js"></script> <script src="res/loading.js"></script>
<canvas id="gameCanvas" width="480" height="720"></canvas> <canvas id="gameCanvas" width="480" height="720"></canvas>
<script>
(function () {
var nav = window.navigator;
var ua = nav.userAgent.toLowerCase();
var uaResult = /android (\d+(?:\.\d+)+)/i.exec(ua) || /android (\d+(?:\.\d+)+)/i.exec(nav.platform);
if (uaResult) {
var osVersion = parseInt(uaResult[1]) || 0;
var browserCheck = ua.match(/(qzone|micromessenger|qqbrowser)/i);
if (browserCheck) {
var gameCanvas = document.getElementById("gameCanvas");
var ctx = gameCanvas.getContext('2d');
ctx.fillStyle = '#000000';
ctx.fillRect(0, 0, 1, 1);
}
}
})();
</script>
<script src="frameworks/cocos2d-html5/CCBoot.js"></script> <script src="frameworks/cocos2d-html5/CCBoot.js"></script>
<script cocos src="main.js"></script> <script cocos src="main.js"></script>
</body> </body>

View File

@ -4,7 +4,7 @@
<meta charset="utf-8"> <meta charset="utf-8">
<title>Cocos2d-html5 Hello World test</title> <title>Cocos2d-html5 Hello World test</title>
<link rel="icon" type="image/GIF" href="res/favicon.ico"/> <link rel="icon" type="image/GIF" href="res/favicon.ico"/>
<meta name="viewport" content="width=480, initial-scale=1"> <meta name="viewport" content="initial-scale=1">
<meta name="apple-mobile-web-app-capable" content="yes"/> <meta name="apple-mobile-web-app-capable" content="yes"/>
<meta name="full-screen" content="yes"/> <meta name="full-screen" content="yes"/>
<meta name="screen-orientation" content="portrait"/> <meta name="screen-orientation" content="portrait"/>
@ -23,6 +23,23 @@
<body style="padding:0; margin: 0; background: #000;"> <body style="padding:0; margin: 0; background: #000;">
<script src="res/loading.js"></script> <script src="res/loading.js"></script>
<canvas id="gameCanvas" width="480" height="720"></canvas> <canvas id="gameCanvas" width="480" height="720"></canvas>
<script>
(function () {
var nav = window.navigator;
var ua = nav.userAgent.toLowerCase();
var uaResult = /android (\d+(?:\.\d+)+)/i.exec(ua) || /android (\d+(?:\.\d+)+)/i.exec(nav.platform);
if (uaResult) {
var osVersion = parseInt(uaResult[1]) || 0;
var browserCheck = ua.match(/(qzone|micromessenger|qqbrowser)/i);
if (browserCheck) {
var gameCanvas = document.getElementById("gameCanvas");
var ctx = gameCanvas.getContext('2d');
ctx.fillStyle = '#000000';
ctx.fillRect(0, 0, 1, 1);
}
}
})();
</script>
<script src="frameworks/cocos2d-html5/CCBoot.js"></script> <script src="frameworks/cocos2d-html5/CCBoot.js"></script>
<script cocos src="main.js"></script> <script cocos src="main.js"></script>
</body> </body>

View File

@ -122,6 +122,8 @@ cc.game.onStart = function(){
} }
else else
{ {
cc.view.setDesignResolutionSize(800, 450, cc.ResolutionPolicy.SHOW_ALL);
cc.view.resizeWithBrowserSize(true);
// js-test use cpptest resource in debug mode , and in the release mode, console will copy the resource into the res dir // js-test use cpptest resource in debug mode , and in the release mode, console will copy the resource into the res dir
// so the respath will modify to res, // so the respath will modify to res,
if (cc.game.config[cc.game.CONFIG_KEY.engineDir] !== "frameworks/cocos2d-html5") { if (cc.game.config[cc.game.CONFIG_KEY.engineDir] !== "frameworks/cocos2d-html5") {

View File

@ -6,7 +6,6 @@
<link rel="icon" <link rel="icon"
type="image/GIF" type="image/GIF"
href="res/Images/favicon.ico"/> href="res/Images/favicon.ico"/>
<meta name="viewport" id="viewport" content="width=480,user-scalable=no" />
<style> <style>
body, canvas, div { body, canvas, div {
@ -19,7 +18,8 @@
</style> </style>
</head> </head>
<body style="padding:0; margin: 0; background: #fff;"> <body style="padding:0; margin: 0; background: #fff;">
<canvas id="gameCanvas" width="480" height="320"></canvas> <canvas id="gameCanvas" width="480" height="320"></canvas>
<script src="tests-boot-html5.js"></script> <script src="../../web/CCBoot.js"></script>
<script src="main.js"></script>
</body> </body>
</html> </html>

View File

@ -127,12 +127,103 @@ var BakeLayerTest1 = BakeLayerBaseTest.extend({
} }
}); });
var BakeLayerTest2 = BakeLayerBaseTest.extend({
_bakeLayer: null,
title:function () {
return "Test 2. Bake Layer with other layer (Canvas only)";
},
subtitle: function () {
return "Changing top layer shouldn't increase draw call number";
},
ctor: function(){
this._super();
var winSize = cc.winSize;
var bakeItem = new cc.MenuItemFont("bake", this.onBake, this);
var unbakeItem = new cc.MenuItemFont("unbake", this.onUnbake, this);
var chTopItem = new cc.MenuItemFont("change top layer", this.onChangeZOrder, this);
var chBakeItem = new cc.MenuItemFont("change bake layer", this.onChangeBakeZOrder, this);
var menu = new cc.Menu(bakeItem, unbakeItem, chTopItem, chBakeItem);
menu.alignItemsVertically();
menu.x = winSize.width - 70;
menu.y = winSize.height - 120;
this.addChild(menu, 10);
var rootLayer = new cc.Layer();
rootLayer.setPosition(20,20);
this.addChild(rootLayer);
var bakeLayer = new cc.Layer();
bakeLayer.bake();
bakeLayer.setRotation(30);
rootLayer.addChild(bakeLayer);
for(var i = 0; i < 9; i++){
var sprite1 = new cc.Sprite(s_pathGrossini);
if (i % 2 === 0) {
sprite1.setPosition(50 + i * 30, winSize.height / 2 - 150);
} else {
sprite1.setPosition(50 + i * 30, winSize.height / 2 - 100);
}
if(i === 4)
this._actionSprite = sprite1;
sprite1.rotation = 360 * Math.random();
bakeLayer.addChild(sprite1);
}
this._bakeLayer = bakeLayer;
var normalLayer = new cc.Layer();
rootLayer.addChild(normalLayer);
for(var i = 0; i < 9; i++){
var sprite1 = new cc.Sprite(s_pathSister1);
if (i % 2 === 0) {
sprite1.setPosition(400 + i * 40, winSize.height / 2 - 50);
} else {
sprite1.setPosition(400 + i * 40, winSize.height / 2 + 50);
}
if(i === 4)
this._actionSprite = sprite1;
sprite1.rotation = 360 * Math.random();
normalLayer.addChild(sprite1);
}
this._normalLayer = normalLayer;
this.zOrder = 0;
},
onBake: function(){
this._bakeLayer.bake();
},
onUnbake: function(){
this._bakeLayer.unbake();
},
onChangeZOrder: function(){
this.zOrder++;
var childId = Math.floor(Math.random() * 9);
this._normalLayer.children[childId].setLocalZOrder(this.zOrder);
this._normalLayer.children[childId].rotation = 360 * Math.random();
},
onChangeBakeZOrder: function(){
this.zOrder++;
var childId = Math.floor(Math.random() * 9);
this._bakeLayer.children[childId].setLocalZOrder(this.zOrder);
}
});
var BakeLayerColorTest = BakeLayerBaseTest.extend({ var BakeLayerColorTest = BakeLayerBaseTest.extend({
_bakeLayer: null, _bakeLayer: null,
_actionSprite: null, _actionSprite: null,
title:function () { title:function () {
return "Test 2. Bake Layer Gradient (Canvas only)"; return "Test 3. Bake Layer Gradient (Canvas only)";
}, },
ctor: function(){ ctor: function(){
@ -210,6 +301,7 @@ var BakeLayerTestScene = TestScene.extend({
// //
var arrayOfBakeLayerTest = [ var arrayOfBakeLayerTest = [
BakeLayerTest1, BakeLayerTest1,
BakeLayerTest2,
BakeLayerColorTest BakeLayerColorTest
]; ];

View File

@ -130,6 +130,10 @@ var S9BatchNodeBasic = S9SpriteTestDemo.extend({
cc.log("this..addChild"); cc.log("this..addChild");
cc.log("... S9BatchNodeBasic done."); cc.log("... S9BatchNodeBasic done.");
var moveBy = cc.moveBy(1, cc.p(80, 80));
var moveByBack = moveBy.reverse();
blocks.runAction(cc.sequence(moveBy,moveByBack));
} }
}); });
@ -159,6 +163,10 @@ var S9FrameNameSpriteSheet = S9SpriteTestDemo.extend({
cc.log("this..addChild"); cc.log("this..addChild");
cc.log("... S9FrameNameSpriteSheet done."); cc.log("... S9FrameNameSpriteSheet done.");
var moveBy = cc.moveBy(1, cc.p(80, 80));
var moveByBack = moveBy.reverse();
blocks.runAction(cc.sequence(moveBy,moveByBack));
} }
}); });

2
web

@ -1 +1 @@
Subproject commit 56c240983a8c7a6b221f840e3c45ed3d733ef102 Subproject commit 116c3c9ac13354cd62e65dc4ef48738fa9872340