问题复现:
->cocos2dx 3.17.2(js)、windows模拟器、Android真机
->场景A切换到场景B
->场景A有clippingNode子节点
->使用部分需要fbo的场景效果(比如TransitionFadeTR)
->效果是白屏和场景B做切换。
问题截图:
查了比较久,比较相近的是这个issue:[Win7 CppTests]Don’t see the expected behavior in ‘Node:Clipping–>Clipping to RenderTexture Test’,但也是很久之前的了
想问问有没有同样问题的小伙伴?难道只有我这样?也求官方给思路
在web模板项目基础上写了个用例,官方可以测试下
var res = {
HelloWorld_png : "res/HelloWorld.png",
pic1 : "res/pic1.jpg",
pic2 : "res/pic2.jpg",
};
var getRes = (function(num) {
return function() {
num++;
if (num % 2 === 0) {
return res.pic1;
}
if (num % 2 === 1) {
return res.pic2;
}
};
})(0);
// 添加了clippingNode的精灵类
var TestSprite = cc.Sprite.extend({
ctor: function() {
this._super();
var stencil = new cc.Layer();
var stencilSprite = new cc.Sprite(res.HelloWorld_png);
stencilSprite.attr({
x : 0,
y : 0,
anchorX : 0,
anchorY : 0
})
stencil.addChild(stencilSprite);
var clippingPanel = new cc.ClippingNode();
clippingPanel.attr({
x : 0,
y : 0,
anchorX : 0,
anchorY : 0
})
clippingPanel.stencil = stencil;
clippingPanel.setCascadeOpacityEnabled(true);
clippingPanel.setInverted(false);
this.clippingPanel = clippingPanel;
this.addChild(this.clippingPanel);
var label = new cc.LabelTTF('我是文字', '', 100);
// var label = new cc.Sprite(res.HelloWorld_png);
label.attr({
anchorX : 0,
anchorY : 0
})
this.clippingPanel.addChild(label);
}
});
var TestScene = cc.Scene.extend({
ctor: function() {
this._super();
var s1 = new cc.Sprite(getRes());
s1.attr({
width: cc.winSize.width,
height: cc.winSize.height,
anchorX: 0,
anchorY: 0
});
this.addChild(s1);
this.addChild(new TestSprite());
},
onEnter: function() {
this._super();
setTimeout(function() {
var transitionScene = new cc.TransitionFadeTR(1, new TestScene());
cc.director.runScene(transitionScene); //每次切换会白屏,只留clippingNode的节点
}, 2000);
}
});
可以在window环境跑下我这个用例TestTransition.zip (402.0 KB)
求答疑,求解决