Spin wheel

birnesoft

Active Member
Licensed User
Longtime User
Time Set via Scrollview B4A

Hallo,

I was asking the same to me.

Here is my solution, nearly like a wheel.


wheel.jpg


:sign0013:,the code is very dirty.

hope you can use for your case.

good luck

Björn Roth
 

Attachments

  • wheel.zip
    332.6 KB · Views: 937

Erel

B4X founder
Staff member
Licensed User
Longtime User
Thank you for sharing this.
You should use 'dip' units for all the pixels size values. Otherwise it will not scale correctly.

On the device I tested it the white lines are not in the exact correct position.

You should use File - Export as zip when uploading files to the forum. The current zip file includes many unnecessary files.
 

Frankt

New Member
Licensed User
Longtime User
:sign0163:
Anyone have an idea for a endless spin box?
After the number 59 return to 1 to have a real spin like the big wheel in the show "price is right".
 
D

Deleted member 103

Guest
Hi birnesoft,

Thank you for your Spin-wheel.

I've improved a bit on your code to make it a little better.


Ciao,
Filippo
 

Attachments

  • wheel_v2.zip
    6.9 KB · Views: 568

JoanRPM

Active Member
Licensed User
Longtime User
Hello birnesoft.
I have made other improvements based on your example.
Just improve the graphic look and gives a bit more realism.
Thanks.
 

Attachments

  • wheel_jr1.zip
    7.9 KB · Views: 505

birnesoft

Active Member
Licensed User
Longtime User
Wheel V3

Hallo,

:sign0098:
JoanRPM looks great,
and thanks Filippo for optimize the code.

I made it now more flexible with arrays.

wheel3.jpg


Good Idea with the dip is more easy. Thanks Erel!

Have anyone an idea to get the timer index on a better way?
And how can I make lines over the views.
I made it with __________ but it's not exact.


here is the whole src
thanx for optimize it!!!
Sub Process_Globals
Dim Timer(10) As Timer

End Sub

Sub Globals

Dim Panel1(10) As Panel
Dim pp(10) As Int 'ScrollView Positions
Dim vv(10) As String'selected value

Dim L1 As Label
Dim sv(10) As ScrollView
Dim fi As String
Dim Label1 As Label
Dim Label2 As Label

Dim Label3 As Label
Dim Label4 As Label
Dim Label5 As Label
Dim Label6 As Label
End Sub

Sub Activity_Create(FirstTime As Boolean)

Activity.LoadLayout("main")
For ii = 0 To 2
Timer(ii).Initialize("TimerX", 700+ii) ' 1000 = 1 second
sv(ii).Initialize2(666,"ScrollViewX")
sv(ii).Tag=ii
Activity.AddView(sv(ii),30dip+(70dip*ii),70dip,70dip,100dip)

Select ii
Case 0
SetupScrollViews(ii,24)
Case 1
SetupScrollViews(ii,59)
Case 2
SetupScrollViews(ii,59)
End Select

Next

Label1.BringToFront
Label2.BringToFront

For ii = 3 To 5
Timer(ii).Initialize("TimerX", 700+ii) ' 1000 = 1 second
sv(ii).Initialize2(666,"ScrollViewX")
sv(ii).Tag=ii
Activity.AddView(sv(ii),30dip+(70dip*(ii-3)),230dip,70dip,100dip)

Select ii
Case 3
SetupScrollViews(ii,24)
Case 4
SetupScrollViews(ii,59)
Case 5
SetupScrollViews(ii,59)
End Select

Next

Label4.BringToFront
Label5.BringToFront

DoEvents

For ii = 0 To 5
pp(ii)=Rnd(0,12)*55
sv(ii).ScrollPosition=Round(pp(ii)/55)*55+5
Next

End Sub

Sub SetupScrollViews(ii As Int, z As Int)
Panel1(ii)= sv(ii).Panel
For i = 0 To z
Dim Label1 As Label
Label1.Initialize("")
Label1.Color=Colors.LightGray
Label1.textColor=Colors.Black
Label1.TextSize=24
Label1.Gravity=Gravity.CENTER
Label1.Text=NumberFormat( i,2,0)
Panel1(ii).AddView(Label1,3,(i+1)*55,96,58)
Next
Panel1(ii).Height=55*i+111
Panel1(ii).Color = Colors.DarkGray
End Sub

Sub ScrollViewX_ScrollChanged(Position As Int)
Dim index As Int
Dim SV1 As ScrollView
SV1=Sender
index=SV1.Tag
pp(index)=Position
Timer(index).Enabled = True
End Sub

Sub TimerX_Tick
Dim index As Int
Dim ti As Timer
ti=Sender
index=ti.Interval-700 'sorry ;-)) the timer has no tag
sv(index).ScrollPosition=Round(pp(index)/55)*55+5
Timer(index).Enabled = False
vv(index)=Round(pp(index)/55)
vv(index)="0"&vv(index)
vv(index)=vv(index).SubString(vv(index).Length-2)

Activity.Title=vv(0)&":"&vv(1)&":"&vv(2)
End Sub
 

Attachments

  • wheelv3.0.zip
    6.8 KB · Views: 571
Last edited:

birnesoft

Active Member
Licensed User
Longtime User
sure you have a long night!

:sign0163:
Anyone have an idea for a endless spin box?
After the number 59 return to 1 to have a real spin like the big wheel in the show "price is right".

you have to add 2 panels with the label list in the panel from the scrollview
if the position is on the end, position the first panel.top to the second panel bottom and change the position of the scrollview to the right place.

if you realize this for good handling I make a
Laola-Welle :wav: (Mexican wave)
for you
good luck!!!
 

birnesoft

Active Member
Licensed User
Longtime User
Yeah!!

I've added a transparent PNG with lines.

also for this I give an Laola :wav:

1000 Thanks,
now it looks perfect!

only the handling is still uncomfortable.

I think about a second timer array to make the moving more smooth.
 

moster67

Expert
Licensed User
Longtime User
:sign0098:

What a nice teamwork you have done!

This wheel-view is really nice and can add really nice looks to an app just like in the example Filippo posted.
 

Frankt

New Member
Licensed User
Longtime User
Thanks to everyone !

I think you can give a star to birnesoft for his contribution !
Nice team work !
:sign0142:
 
D

Deleted member 103

Guest
Hi birnesoft,

Idea:
for some cases it's maybe good to start the time again.
with the new version it is now possible, thanks for the tip.

Ciao,
Filippo
 

birnesoft

Active Member
Licensed User
Longtime User
Hi birnesoft,


with the new version it is now possible, thanks for the tip.

Ciao,
Filippo

Yes good. Now you can make a funny game with much people. who drives the longest time with an unicycle in 5 minutes :-D
It will also be good to make Names or photos with the camera before the start button.
Also an option to set all the conters on your choosen countdown time will be comfortable
and a bargraph behind the time to see visually how much time is left for each Person

I'm happy when you use my ideas, and I can use your tool for free.

thanks
Birne
 

birnesoft

Active Member
Licensed User
Longtime User
Cabatibility Update Spin Wheel 4.0

On Galaxy Note the white lines are going through the numbers.
(Using the actual version.)

Yes Erel told me too, I have to use dip's for positions to make it compatible.
I was long think about dip with variables.
Now I use this way

:sign0074: position= X*1dip

it works fine!!

In this version I've made it more flexible
and a better handling of the wheel
by setting the justify-time two times higher
now it' more relaxed

You can change this now more comfortable:

lh=45 'Labelheight
lOffSet=8 'label Center
timerCount=1500 'to Center the choosen Label

Good work with it!

>:)-D)Birne

PS.:has anybody an better idea to get the timer index??
 

Attachments

  • wheel_v40.zip
    7.3 KB · Views: 641
Last edited:
Top