Skip to main content

Microsoft Silverlight

Answered Question Slot Machine Implementation GuidanceRSS Feed

(0)

halhunt
halhunt

Member

Member

0 points

4 Posts

Slot Machine Implementation Guidance

Hello,

 I am looking for some guidance in developing a SL3 app that mimics this flash app:

http://www.urbanspoon.com/spin-widget

My first thoughts were to use a ScrollViewer containing a Stackpanel (oriented vertically) containing a bunch of text blocks and just use the ScrollViewer.ScrollToVerticalOffset to control the movement of the slot.  That all worked and was very simple to do.  Now I'm trying to figure out how to actually simulate the "spin" of the slot.  Any suggestions are greatly appreciated!

Thanks in advance!

drnomad
drnomad

Member

Member

206 points

58 Posts

Re: Slot Machine Implementation Guidance

If your control rotates the items round the wheel, then I guess the simulation is very simple by manipulating the scroll speed. In your example, they have also made the text a little vague, to make the rotation a little more convincing.

Online Silverlight games on http://www.seujogo.com

ben33333
ben33333

Member

Member

50 points

11 Posts

Re: Slot Machine Implementation Guidance

 I think you're having trouble because the HorizontalOffset and VerticalOffset of ScrollViewer are read-only in Silverlight.  However, there are workarounds:

http://blogs.msdn.com/delay/archive/2009/08/04/scrolling-so-smooth-like-the-butter-on-a-muffin-how-to-animate-the-horizontal-verticaloffset-properties-of-a-scrollviewer.aspx

That will probably work well with what you have already created.  An alternative would be to place your StackPanel inside a Canvas and animate a TranslateTransform instead.

 For the blur look, you could either overlay a blurred-text image over your text blocks, or use a pixel shader if you want something more advanced.

halhunt
halhunt

Member

Member

0 points

4 Posts

Re: Re: Slot Machine Implementation Guidance

Thanks so much for your reply Ben.  I will look over the link you suggested too.  I guess my challenge is that the items in each of my slots are less than 10 items long so I'm not sure how to make them "wrap" around like a wheel.  So when the user "spins" the slot the whole items list is repeated again.  I think if I used a StackPanel inside a canvas I would have the same issue.  Does that make any sense?

halhunt
halhunt

Member

Member

0 points

4 Posts

Re: Re: Re: Slot Machine Implementation Guidance

Any other suggestions on ways to accomplish this are very much appreciated!

Jonathan Shen – MSFT
Jonathan...

All-Star

All-Star

24979 points

2,434 Posts

Microsoft
Answered Question

Re: Slot Machine Implementation Guidance

Hi Halhunt,

I just took a look at the application.  This can be down with Silverlight.  We can simply add tree ListBox to show the Three Columns.  Each column has two buttons, one for up and another for down operation.  When we click to Spin, we can a WCF to get the target restaurant, and during this, we can show an animation or change the ListBox's ItemsSource with a fake data.

Best regards,

Jonathan

 

Jonathan Shen
Microsoft Online Community Support
Please remember to mark the replies as answers if they help and unmark them if they provide no help.

halhunt
halhunt

Member

Member

0 points

4 Posts

Re: Re: Slot Machine Implementation Guidance

Here is the final product:

http://www.shakedate.com

Enjoy!

  • Unanswered Question
  • Answered Question
  • Announcement
Microsoft Communities