Rotating actor with slider

skottskott Member Posts: 172
edited November -1 in Working with GS (Mac)
Hi

I'm trying to create an actor who are rotating through a slider.

THIS IS WHAT I WANNA DO:

- If you drag the slider to the right, the actor will rotate clockwise
- If you drag the slider to the left, the actor will rotate counterclockwise

The volume slider that firemaplegames have made is really great (http://gamesalad.com/game/play/30207 ), and i'm trying to tweak that - but i can't figure it out. Can anyone help with a little assistance

Comments

  • firemaplegamesfiremaplegames Member Posts: 3,211
    well, my slider demo makes the value go from 0 to 1. just multiply the result by 360 to get the angle you want...

    i.e, if the slider is halfway, or 0.5, multiply that by 360 to get 180...

    does that make sense?
  • skottskott Member Posts: 172
    tshirtbooth: Yes it's an whole different ball game :) rotation depends on where the slider is.. Rotation follows the slider.

    firemaplegames: yes it does make sense, but i'm not that long yet. I'm still trying to understand the code you have made. I have made an actor (the rotating object) I guess that I should make some change attribute and rotation on that..

    I'm no great coder at all, i'm more into graphic so maybe this is a long shot - but I know it would fit perfect to that game i'm making.
  • skottskott Member Posts: 172
    yeah be nice to me guys, i'm a code rookie.. hehe
  • HunnenkoenigHunnenkoenig Member Posts: 1,173
    I didn't want to make a new topic, because I want to do something similar, but I can't figure out.

    I have an actor which I move vertically by constraining the mouse position. So it is a slider. Now there is another actor in front of the slider a liitle bit offset.

    I have the offset length and if I move the slider, the other actor moves with the slider.

    What I want to do is the actor should move a bit quicker than the slider, so the length difference between slider and actor gets bigger and bigger.

    If this makes sense to you, I would appreciate a little help.
  • HunnenkoenigHunnenkoenig Member Posts: 1,173
    Nobody?
  • PhoticsPhotics Member Posts: 4,172
    If they're starting from the same point, I'm thinking that you'd simply multiply the Y mouse position.

    Something like...
    Constrain Actor Y Position to (Mouse Y)*1.2

    If they don't start at the same point, the math gets tricky... but I don't think it's impossible.
  • firemaplegamesfiremaplegames Member Posts: 3,211
    I'm not sure if I understand your question exactly, but I made this demo that shows how to create a scrollbox:

    http://gamesalad.com/game/play/37404

    It might be similar to what you're asking. It uses ratios to move the content based on the slider position. (the content can be of any length)

    Maybe there's something in there that you can pick apart?
  • HunnenkoenigHunnenkoenig Member Posts: 1,173
    Thanks for reply.

    Photics solution with *1.2 seems to work, but not perfect.
    When I use it, my icon jumps to another position and then starts moving like I want to be moved. Now I have to try to keep it in the original position at the first click.

    ----

    Firemaple, I want to do something very similar, but I don't know if I can use your demo.

    Speaking in terms of your demo, I want the text going down, when I pull the slider down, but the first line of the text should be at the bottom, when the slider is half way.

    Your demo does something like that in the other direction, but I don't know, how to change your math accordingly.

    in my case:
    if touch pressed on slider, I constrain the slider's Y to game.sliderY
    I watch the difference between sliderY and TextY
    I constrain on the text self.Y to self.Y - game.sliderY

    So the slider moves the text with itself always with the same difference, where ever it was on the screen at start.

    In my case the problem is, that I spawn an icon, which spawns an icon, which spawns an icon and so forth. I have no fixed height of the content, which I can watch.

    I want to move the icons in the row with the slider, so those icons, which are spawned outside of the screen, can be viewed by moving the slider.
  • HunnenkoenigHunnenkoenig Member Posts: 1,173
    I solved it!

    I just constrain the position.Y of the slider to game.sliderY, then I constrain position.Y to (game.sliderY - XXX)*2 on the actor (icon)

    Where XXX is a number determinig the actor's position.

    The slider has a max-min to not go outside of the screen.

    It works like a charm!
Sign In or Register to comment.