Skip to content

Commit 3be796c

Browse files
committed
1 parent a504c54 commit 3be796c

File tree

1 file changed

+63
-1
lines changed

1 file changed

+63
-1
lines changed

tests/js-tests/src/RenderTextureTest/RenderTextureTest.js

Lines changed: 63 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -654,6 +654,67 @@ var Issue1464 = RenderTextureBaseLayer.extend({
654654
}
655655
});
656656

657+
var RenderTextureWithScrollView = RenderTextureBaseLayer.extend({
658+
_scroll: null,
659+
660+
ctor:function() {
661+
this._super();
662+
663+
var backSprite = new cc.Sprite(s_back1);
664+
665+
backSprite.x = winSize.width/2;
666+
backSprite.y = winSize.height/2;
667+
668+
this.addChild(backSprite, 1);
669+
670+
this._scroll = new ccui.ListView();
671+
this._scroll.setDirection(ccui.ScrollView.DIR_HORIZONTAL);
672+
this._scroll.setContentSize(winSize.width, winSize.height);
673+
this._scroll.setPosition(winSize.width/4, winSize.height/4);
674+
this._scroll.setBounceEnabled(true);
675+
676+
this.addChild(this._scroll, 2);
677+
678+
var callfunc = cc.callFunc(this._addRenderTextureNode, this);
679+
680+
this.runAction(cc.sequence(cc.delayTime(0.1), callfunc));
681+
},
682+
683+
_addRenderTextureNode: function()
684+
{
685+
var sprite = new cc.Sprite(s_grossini);
686+
687+
// create a render texture
688+
var rend = new cc.RenderTexture( winSize.width/2, winSize.height/2 );
689+
690+
sprite.x = winSize.width/2;
691+
sprite.y = 3*winSize.height/4;
692+
693+
rend.begin();
694+
sprite.visit();
695+
rend.end();
696+
697+
var texture = rend.getSprite().getTexture();
698+
var spr = new cc.Sprite(texture);
699+
spr.setScaleY(-1);
700+
spr.setAnchorPoint(0, 0);
701+
702+
var layout = new ccui.Layout();
703+
layout.addChild(spr);
704+
layout.setContentSize(spr.getContentSize());
705+
706+
this._scroll.pushBackCustomItem(layout);
707+
},
708+
709+
title:function () {
710+
return "Render Texture and ScrollView";
711+
},
712+
713+
subtitle:function () {
714+
return "Background and rendered sprites must be visible, not a black screen";
715+
}
716+
});
717+
657718

658719
var RenderTextureTestScene = TestScene.extend({
659720
runThisTest:function (num) {
@@ -670,7 +731,8 @@ var RenderTextureTestScene = TestScene.extend({
670731
//
671732
var arrayOfRenderTextureTest = [
672733
RenderTextureSave,
673-
Issue1464
734+
Issue1464,
735+
RenderTextureWithScrollView
674736
];
675737

676738
if(('opengl' in cc.sys.capabilities) && cc._renderType === cc.game.RENDER_TYPE_WEBGL && (!cc.sys.isNative) ){

0 commit comments

Comments
 (0)