Search code examples
cocos2d-xcocos2d-x-3.0

How to set the scroll position in ui::ScrollView programmatically?


Say I have a scrollview whose contentSize is the size of the visible screen

Eg:

Content Size = 320 x 480
InnerContainer = 900 x 480

How can I set the scroll position programmatically ? For example, if there is an object at (400,100), how would I programmatically scroll the view so that the object is visible ?

There seems to be methods for setting the scroll bar position, but I don't think that actually scrolls the view.

I am using cocos2d-x v3.10


Solution

  • Use: setInnerContainerPosition()