Widget player selection difficult to optimize

Hi guys,

I am finishing one game and would appreciate your help with widget/player selection.

Here is the widget code:

local function showSlidingMenu( event )         scrollView = widget.newScrollView         {             width = 460,             height = 100,             scrollWidth = 2000,             scrollHeight = 100,             verticalScrollDisabled = true         }         scrollView.x = display.contentCenterX         scrollView.y = display.contentCenterY         local scrollViewBackground = display.newRect( 1000, 50, 2000, 100 )         scrollViewBackground:setFillColor( 0, 0, 0.2 )         scrollView:insert( scrollViewBackground )         --generate icons         for i = 1, 20 do         local sprite\_info\_player = SpritesPlayers[i] -- DO NOT MIND THIS, IT IS DEFINED ABOVE             player[i] = display.newSprite(sprite\_info\_player.image\_sheet, sprite\_info\_player.sequence\_data )             player[i].x = i \* 100             player[i].y = 50             scrollView:insert( player[i] )             player[i].id = i             player[i]:addEventListener( "touch", iconListener )                      end     return true end

I took this code from widget tutorial:

https://coronalabs.com/blog/2014/08/19/tutorial-building-a-sliding-menu/

Basicly my two main problems are:

1) Standardize numbers 460, 100, 2000, 1000 across all devices (how to connect them with screenHeight, screenWidth variables)… ?

  1. I can never center  scrollViewBackground nicely, either it goes much off Right, or it is too short, or you simply see ugly white widget background when you pull widget too hard.

Is there any nicer solution for player selection out there?

Many thanks!  :slight_smile:

Ivan

You seem to have several things going on. Let’s work backwards.

I think there is an option to stop scrollViews from being pullable beyond the bounds. See the .isBounceEnabled option.

Now for the background, if it’s just going to be a solid color, why not make the scrollView background invisible and just drop the color rectangle underneath it? It would simplify things greatly.  

Now for the first problem, this is going to be tough to answer without seeing some screen shots or your config.lua and a description of what screen real estate the scrollView should be occupying and what your UI goals are.

For instance I don’t know if you have an edge-to-edge scrollView or is it only taking up part of the screen? If you can provide more information the community will have more information to work with.

Rob

Thanks Rob for all information!

I have solved this with your kind suggestions!  :slight_smile:

New hit game is comming up soooon  :smiley:

Ivan

You seem to have several things going on. Let’s work backwards.

I think there is an option to stop scrollViews from being pullable beyond the bounds. See the .isBounceEnabled option.

Now for the background, if it’s just going to be a solid color, why not make the scrollView background invisible and just drop the color rectangle underneath it? It would simplify things greatly.  

Now for the first problem, this is going to be tough to answer without seeing some screen shots or your config.lua and a description of what screen real estate the scrollView should be occupying and what your UI goals are.

For instance I don’t know if you have an edge-to-edge scrollView or is it only taking up part of the screen? If you can provide more information the community will have more information to work with.

Rob

Thanks Rob for all information!

I have solved this with your kind suggestions!  :slight_smile:

New hit game is comming up soooon  :smiley:

Ivan