how to use ccs.ScrollView

how to use ccs.ScrollView
0.0 0


var scroll = ccs.ScrollView.create();
scroll.setInnerContainerSize(cc.SizeMake(100, 100));
var bgSprite = cc.Sprite.create(s_bg);

Sprite can’t show.
Please give me an example


Hi, I’ve posted about this problem (and even created a support issue) too: the examples given in the samples/tests directory are difficult to understand, so I can’t help you with this.

In my case, I ended up creating a Layer and implementing my own scroll (and zoom) methods for it. It’s really an easier logic than one might think, so if you don’t have a particular need to use CCSScrollView, I advice you try to implement the logic yourself.


This a example about scrollView. But i suggest you create a ccs.ScrollView with cocostudio edtor.

        var scrollView = ccs.ScrollView.create();
        scrollView.setSize(cc.size(200, 100));

        var imageView = ccs.ImageView.create();
        var uiLayer = ccs.UILayer.create();


Yeah, but, there are cases in which going to CocoStudio is overkill: all we want is to empower some sprite or layer with the ability to be scrolled and contained in an area. And with just that code snippet alone (which is fairly simmilar to the one in the test cases), with no comments on what line of code does what (specially in the sizes and positions settings) I just can’t seem to make it behave just right (for example: I get my image to show, but I can’t scroll it, or I can only scroll it a little bit in one direction).

I know you are probably used to this code and think it’s obvious, but would you mind explaining it a bit?



Thank you for your help!


Please help me to scroll the view pagewise…
thanks in advance…