playMaker

Author Topic: How to create a 'stepped' slider?  (Read 2819 times)

JennaReanne

  • Junior Playmaker
  • **
  • Posts: 57
    • Little Worlds Interactive
How to create a 'stepped' slider?
« on: January 28, 2014, 02:02:59 PM »
Hi all,
I'm trying to create a stepped slider (not sure if there's a better term for it).  Basically the slider would go from 1-5, but players can only select 1, 2, 3, 4 or 5.  The slider button snaps between those values, and it's not possible to select something in between.

I have some ideas about how to create a basic slider using constraints, but I'm not sure where to begin getting the button to snap to the values.

Thank you!
-Jenna

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: How to create a 'stepped' slider?
« Reply #1 on: January 31, 2014, 06:41:47 AM »
Hi,

 What GUI solution are you using? Unity, Ngui else?


bye,

 Jean

JennaReanne

  • Junior Playmaker
  • **
  • Posts: 57
    • Little Worlds Interactive
Re: How to create a 'stepped' slider?
« Reply #2 on: February 03, 2014, 09:27:51 AM »
I'm hand-building all the GUI elements myself, though I'm considering trying out Daikon Forge.  I was actually able to find a way to get this working - it may not be super elegant, but it functions!  I'll share it here in case it's helpful to anybody else:

Slider consists of 8 objects:
- Background bar graphic
- 5 slider points: empty game objects spread along the bar, these are the 5 points I want to snap to
- Visible button (sprite)
- Invisible button (gameobject with box collider)

The invisible button starts right on top of the visible button.  This is what the player grabs and drags when they go to slide the button.  The 5 slider points are in an ArrayList.  When the invisible button is being dragged it is looking to find the closest slider point every frame.  When the closest slider point changes (ie the invisible button you're dragging is now closer to point 2 than point 1), it sends a message to the visible button sprite to change it's location to the new closest point.  This lets the visible button sprite "step" between the different slider points as you drag.  On mouse up, the invisible button changes it's position back to the visible button, so that you can drag it again.

Hope that makes sense :)

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: How to create a 'stepped' slider?
« Reply #3 on: February 04, 2014, 05:59:18 AM »
Hi,

 I think you are tring to reinvent the wheel. Is it just a scrolling list of items you need? NGUI has an example on this actually. do you own Ngui?

Doing this manually, is involving, but feasible, if you have Daikon Forge, I would ask them if they have already a built in system for this actually.

bye,

 Jean

JennaReanne

  • Junior Playmaker
  • **
  • Posts: 57
    • Little Worlds Interactive
Re: How to create a 'stepped' slider?
« Reply #4 on: February 10, 2014, 10:08:15 AM »
Hi Jean,
No, what I'm trying to do is a bit different.  I do have NGUI but I've never really figured out how to get it to work.  I'm planning on looking into Daikon Forge next, does that connect reasonably well with Playmaker?

Thanks,
Jenna

parallel

  • Full Member
  • ***
  • Posts: 155
Re: How to create a 'stepped' slider?
« Reply #5 on: February 10, 2014, 11:14:06 AM »
Quote from: JennaReanne link=topic=6181.msg30698#msg30698  I'm planning on looking into Daikon Forge next, does that connect reasonably well with Playmaker?
[/quote
It has a lot of actions and I'm enjoying working with it. It comes with a stepped slider right out of the box, as you can set the step increment.