I’ve been trying to create an image slider, that consists of several images. I need to create a scrollView that can have stops between images. The problem is, I don’t know how to load multiple image into the scrollView. Any source documentation I can refer to?
here is what i got so far
function scene:createScene(event) group = self.view local background = display.newImage("Assets/background/background\_1.jpg", 380, 480) group:insert(background) local scrollView = widget.newScrollView { top = 100, left = 60, width = 650, height = 800, scrollWidth = 600, scrollHeight = 800, verticalScrollDisabled = true, } local test = display.newImage( "Assets/objects/01/1\_1.png", 380, 480 ) local test2 = display.newImage( "Assets/objects/01/1\_2.png", 1080, 480 ) local test3 = display.newImage( "Assets/objects/01/1\_3.png", 1780, 480 ) scrollView:insert( test ) scrollView:insert( test2 ) scrollView:insert( test3 ) end
what I want is to be able to create stops every time the scroll view gets into one image. Any possible method to do that?
There is a sample app in CoronaSDK/SampleCode/Interface/SlideView that will show you how to build an image slider. It does not use a scrollView however.
Now once upon a time, I built a scrollView that had several images that were level select buttons and had it center on the image closest to the center.
You have to use the scrollView’s listener event and watch for the “endedScroll” phase. Then take the current position of the scrollView using :getContentPosition() and calculate where the scrollView needs to go to center on the center most image. Once you know that, you can then use :scrollToPosition() to snap to that position.
Rob
I have been thinking of combining the scrollToPosition() with the scroll listener. But now that you have highlighted the slideview, which one is actually better to use? or does it have different purposes?
oh, just realized and check that slideView is not part of the SDK. It is a built in .lua file. LOL. okay
It depends on what you’re doing. The SlideView isn’t a widget per se, but it’s good at doing photo album type behavior.
Basically I need a slider that run over background. Not a album photo type. And slideView doesn’t have much parameter to disabled, as I want to disabled some of the feature, like the … of … picture at the top of the app.
here is what i got so far
function scene:createScene(event) group = self.view local background = display.newImage("Assets/background/background\_1.jpg", 380, 480) group:insert(background) local scrollView = widget.newScrollView { top = 100, left = 60, width = 650, height = 800, scrollWidth = 600, scrollHeight = 800, verticalScrollDisabled = true, } local test = display.newImage( "Assets/objects/01/1\_1.png", 380, 480 ) local test2 = display.newImage( "Assets/objects/01/1\_2.png", 1080, 480 ) local test3 = display.newImage( "Assets/objects/01/1\_3.png", 1780, 480 ) scrollView:insert( test ) scrollView:insert( test2 ) scrollView:insert( test3 ) end
what I want is to be able to create stops every time the scroll view gets into one image. Any possible method to do that?
There is a sample app in CoronaSDK/SampleCode/Interface/SlideView that will show you how to build an image slider. It does not use a scrollView however.
Now once upon a time, I built a scrollView that had several images that were level select buttons and had it center on the image closest to the center.
You have to use the scrollView’s listener event and watch for the “endedScroll” phase. Then take the current position of the scrollView using :getContentPosition() and calculate where the scrollView needs to go to center on the center most image. Once you know that, you can then use :scrollToPosition() to snap to that position.
Rob
I have been thinking of combining the scrollToPosition() with the scroll listener. But now that you have highlighted the slideview, which one is actually better to use? or does it have different purposes?
oh, just realized and check that slideView is not part of the SDK. It is a built in .lua file. LOL. okay
It depends on what you’re doing. The SlideView isn’t a widget per se, but it’s good at doing photo album type behavior.
Basically I need a slider that run over background. Not a album photo type. And slideView doesn’t have much parameter to disabled, as I want to disabled some of the feature, like the … of … picture at the top of the app.