I am relatively new to corona sdk and trying to implement the slideview of images in corona sdk. I checked the sample code in interfaces/slideView. This code essentially shows one image in a screen and on swiping it shows the other images. How do i show 1 1/2 or 2 images in the screen hinting that we need to swipe for more images.Any pointers would be helpful.
What you need is a scrollViewobject and code the logic yourself. If the width of your screen is say 800px then load images at 600px width and it will be obvious to the user that they can swipe the display.
Thanks for the suggestion. I was able to use the scrollview and insert the images.Thanks for the help.
one more question! I have a back button in my app which goes back to the scrollview.How do i show the last scrolled position?I checked the corona documentation and looks like there is object:getContentPosition() and object:scrollToPosition(), but how do i use it from other scene?
ok, i played around a little bit and found out how to use it…
In the scrollListener , get the scrollviews x value by doing this:
– ScrollView listener
local function scrollListener( event )
local phase = event.phase
if ( phase == “began” ) then print( “Scroll view was touched” )
elseif ( phase == “moved” ) then
x, y = event.target:getContentPosition()
print( “Scroll view was moved” )
elseif ( phase == “ended” ) then print( “Scroll view was released” )
end
– In the event a scroll limit is reached…
if ( event.limitReached ) then
if ( event.direction == “up” ) then print( “Reached bottom limit” )
elseif ( event.direction == “down” ) then print( “Reached top limit” )
elseif ( event.direction == “left” ) then print( “Reached right limit” )
elseif ( event.direction == “right” ) then print( “Reached left limit” )
end
end
return true
end
When I go to other scene:
local customParams={
xValue=x
}
composer.gotoScene( “”,{effect=“fade”, time=400, params=customParams})
On scene2.lua
Retrieve the value of x
function scene:create( event )
local params=event.params
xPos=params.xValue
…
end
Pass this value of x in left button of scene2.lua as:
local customParams={
sample_var=xPos
}
composer.gotoScene( “scrollView”,{effect=“fade”, time=400, params=customParams} )
In scrollview scene:
scroll to this x position by doing this
scrollView:scrollToPosition
{
x = xPos,
y = 0,
time = 800,
--onComplete = onScrollComplete
}
Hope this helps someone. Thanks for the help…
What you need is a scrollViewobject and code the logic yourself. If the width of your screen is say 800px then load images at 600px width and it will be obvious to the user that they can swipe the display.
Thanks for the suggestion. I was able to use the scrollview and insert the images.Thanks for the help.
one more question! I have a back button in my app which goes back to the scrollview.How do i show the last scrolled position?I checked the corona documentation and looks like there is object:getContentPosition() and object:scrollToPosition(), but how do i use it from other scene?
ok, i played around a little bit and found out how to use it…
In the scrollListener , get the scrollviews x value by doing this:
– ScrollView listener
local function scrollListener( event )
local phase = event.phase
if ( phase == “began” ) then print( “Scroll view was touched” )
elseif ( phase == “moved” ) then
x, y = event.target:getContentPosition()
print( “Scroll view was moved” )
elseif ( phase == “ended” ) then print( “Scroll view was released” )
end
– In the event a scroll limit is reached…
if ( event.limitReached ) then
if ( event.direction == “up” ) then print( “Reached bottom limit” )
elseif ( event.direction == “down” ) then print( “Reached top limit” )
elseif ( event.direction == “left” ) then print( “Reached right limit” )
elseif ( event.direction == “right” ) then print( “Reached left limit” )
end
end
return true
end
When I go to other scene:
local customParams={
xValue=x
}
composer.gotoScene( “”,{effect=“fade”, time=400, params=customParams})
On scene2.lua
Retrieve the value of x
function scene:create( event )
local params=event.params
xPos=params.xValue
…
end
Pass this value of x in left button of scene2.lua as:
local customParams={
sample_var=xPos
}
composer.gotoScene( “scrollView”,{effect=“fade”, time=400, params=customParams} )
In scrollview scene:
scroll to this x position by doing this
scrollView:scrollToPosition
{
x = xPos,
y = 0,
time = 800,
--onComplete = onScrollComplete
}
Hope this helps someone. Thanks for the help…