Forum Libraries, Components, and Plugins

CCScrollView - Help Using

I am trying to use CCScrollView and am not having any luck. I used the version of the CCScrollView class in the CocosSharp GitHub Repository .

I tried to make a scrolling list of text boxes. For some context as to why I'm doing this, I'm making a word game where I'd like to show the user a list of correct words at the end. In the example below, what I actually see is the textboxes going outside of their container and no scrolling. (attached)

If you can point me in the right direction, I would really appreciate it!

    public class TestScrollingLayer : CCLayerColor
    CCLayerColor _scrollContainer;

    /// <summary>
    /// Please Help
    /// </summary>
    public void ShowScrollLayer ()
        _scrollContainer = new CCLayerColor (CCColor4B.AliceBlue);
        _scrollContainer.ScaleX = .75F;
        _scrollContainer.ScaleY = .4F;
        _scrollContainer.AnchorPoint = CCPoint.Zero;
        _scrollContainer.Position = CCPoint.Zero;
        float xPos = 0F;
        float yPos = 0F;
        for (int i = 0; i < 20; i++) {
            CCLabel lab = new CCLabel ("Testing 1, 2, 3", "fonts/Champagne___Limousines_Bold.ttf", 70F);
            lab.AnchorPoint = CCPoint.Zero;
            lab.Color = CCColor3B.DarkGray;
            lab.Position = new CCPoint (xPos, yPos);
            _scrollContainer.AddChild (lab);
            yPos = yPos + lab.ContentSize.Height + 3F;

        /// Known bug, CCLayer won't obey size
        CCScrollView wordScrollView = new CCScrollView (new CCSize (200, 200), _scrollContainer);
        wordScrollView.Position = new  CCPoint (0, 0);

        AddChild (wordScrollView);

    public TestScrollingLayer ()
        this.Color = CCColor3B.Black;

    protected override void AddedToScene ()
        base.AddedToScene ();

        ShowScrollLayer ();

    public static CCScene GetScene (CCWindow mainWindow)
        var scene = new CCScene (mainWindow);
        var layer = new TestScrollingLayer ();

        scene.AddChild (layer);

        return scene;



  • xamdevxamdev GBMember


    Could someone throw light on this or point to a sample using the ScrollView.

Sign In or Register to comment.