--JPPicker API JPPicker.activate ( sUserToken, sActivationKey ) sID = JPPicker.addPicker ( hObjectDelegate, nItemCount, nOptStartIndex, bOptScrollOnX, bOptMustStopOnItems ) JPPicker.forceUpdate ( sID ) nItemIndex, nExactItem = JPPicker.getPickerCenterItem ( sID ) nPosition = JPPicker.getPickerPosition ( sID ) nMinPosition, nMaxPosition = JPPicker.getPickerPositionRange ( sID ) nSpeed = JPPicker.getPickerScrollingSpeed ( sID ) tItemsToUpdate, tItemsToDisable, tItemsToEnable = JPPicker.helpMeUpdateMyItems ( sID, nItemsBySide ) bYes = JPPicker.isActive ( sID ) JPPicker.mouseDown ( sID, nPointX, nPointY ) JPPicker.removePicker ( sID ) JPPicker.scrollToIndex ( sID, nItemIndex, bOptInstant ) JPPicker.setActive ( sID, bActive ) JPPicker.setBounceStrengthCoef ( nCoef ) JPPicker.setDampingStrengthCoef ( nCoef ) JPPicker.setMouseCoef ( sID, nCoef ) JPPicker.setPickerOffset ( sID, nOffsetItemCount ) JPPicker.setPickerScrollingSpeed ( sID, nSpeed ) --User notification events: "onPickerScrollingToItem" ( sID, nItemIndex ) "onPickerPositionDidChange" ( sID, nCurrentPosition, nCurrentItemIndex ) "onPickerCenterItemDidChange" ( sID, nItemIndex, bPickerScrollingToAnItemIndex )
A picker is a list of items which can be scrolled and where the item at the middle is the selected one. JPPicker will do all the hard stuff of computing the picker position and will give you the state of the list and the middle item in real time. Then you are free to use the values provided by JPPicker on any kind of elements, for instance HUD components or scene objects.
The JPPicker animation is very pleasant and smooth, there is a bonce effect when the list is out of the start or end position. It is possible to enable an option to make the picker to always end its scrolling on an exact item position.
Its usage is very easy, just tell JPPicker the number of items in the list and you are almost done:
function MyAIModel.onInit ( ) local hObjectDelegate = nil local nItemCount = 20 JPPicker.addPicker ( hObjectDelegate, nItemCount ) end function MyAIModel.onPickerPositionDidChange ( sID, nPosition, nItemIndex ) this.updateItemsPosition ( nPosition ) end function MyAIModel.onPickerCenterItemDidChange ( sID, nIndex, bListCurrentlyScrollingToItem ) this.setSelectedItem ( nIndex ) end
The result is very impressive. Take a look at the JPPicker example in the demo, at the race selection screen.
JPPicker also provides a wonderful function, named JPPicker.helpMeUpdateMyItems, to help you manage your picker in order to have a huge number of items without any performance issues. I have created a tutorial on that subject you should read if you want to learn more about the impact of your Scripting Strategies on your Game Performance.