How do a "snap" a drag movement?

xyloFUNxyloFUN Member Posts: 1,593
edited November -1 in Working with GS (Mac)
Hey guys,
I am looking for a better way to bring in the lessons and songs for one of my apps and wonder, if I would just make a very wide graphic file and let the user slide the content left and right.
The reason I am doing this is that after I watched children play with the trumpet and clarinet, they "wanted" to slide the lessons rather than pushing a button!

Now I know how to constrain movement in one direction but what I don't know is how to "snap" the gfx into place once it is close to a hot spot?
This way, the songs would always be centred.

Has anyone done this before? I'd love to experiment with this a bit and if it makes sense, use that method.

Thanks :)

Comments

  • JohnPapiomitisJohnPapiomitis Member Posts: 6,256
    I think firemaple has a snap and drag demo you could see if that helps, ive never looked at the behaviors though. You could do what you know to start movement and then try when the position is > or < then whatever change its position to what you want, so when it gets slided a certain amount it snaps into place?
  • ScootsScoots Member Posts: 507
    Not sure if this will work for you. But using Gamesmold scrolling menu design shown here by TshirtBooth. You could have your music on 1 layer and your instrument on another layer. Have a look
    http://www.youtube.com/user/GameSaladCookbook#p/u/5/DzaA0gachYM
  • xyloFUNxyloFUN Member Posts: 1,593
    John,
    that is pretty much it!
    I know the with of my graphics (1024 pixels) and the movement would be constrained in the X axis (left right movement only).
    Basically, I don't want a scenario where a song is half cut off or someone sees notes to the left and to the right but nothing in the centre. All could be avoided with making it snap at the centre x axis.
    When the movement is released within 100 pixels, the image would snap in place and the student can then play or keep on moving.
    I think this behaviour would be the best i can implement because the kids are so used to sliding content and I watched over and over, even after pushing the arrow buttons, they still instinctively want to slide the content.

    I will see if i get firemaples demo ....

    thanks :)

    p.s. if you come across something that is workable .... well, don't make me come down there and let the air out of your BMX bike!! LOL
  • JohnPapiomitisJohnPapiomitis Member Posts: 6,256
    OK you could do when touch is press constrain the postition to the touch position. Then when a rule when touch is release and position is > then ( a number youll have to play around with) change position to the all the way left position. Then have another rule in that same instance when position is < (another number youll have to play around and find) change position to all the way right position. Have that when any condition is valid.

    Then do another rule when touch is greater then ( ) but less then ( ) then change attribute to center position. the numbers there will only be a couple plus and minus the center position. So if you only move a tiny bit in any dirfection is goes back to center. But if you move it past a certain point it snaps all the way. ANd if your behind a certain point it snaps the other direction and slides that way.

    I just played around with it and it works. Not sure if there a better way to do it, but that should work :)
  • xyloFUNxyloFUN Member Posts: 1,593
    John,
    I kind of know what you are doing but I can not set this up ...
    would you mind sending me that file so that i can see what you did and make a diagram for myself. Sorry, I am a visual guy and need to see it before I can do it.

    Thanks :)

    p.s. I have a new game idea for you which is unique, (not in itunes) and if you have time to make it ... you could be sailing by my place in a few months :)
  • JohnPapiomitisJohnPapiomitis Member Posts: 6,256
    xyloFUN said:
    John,
    I kind of know what you are doing but I can not set this up ...
    would you mind sending me that file so that i can see what you did and make a diagram for myself. Sorry, I am a visual guy and need to see it before I can do it.

    Thanks :)

    p.s. I have a new game idea for you which is unique, (not in itunes) and if you have time to make it ... you could be sailing by my place in a few months :)

    Sure thing, im gonna try and make a couple things bette then illl send it to you :) And id love to here your idea! Email me, Your other one when was great so im wondering what it could be :)
  • JohnPapiomitisJohnPapiomitis Member Posts: 6,256
    hmm its not working now. Ill try to find the other demos for youu
  • xyloFUNxyloFUN Member Posts: 1,593
    Perfect timing ... i just finished another render and popped back in to see what's new :)

    John, it's ok ... I don't' want you to waste your time with this. I can always add snapping when i update :)

    Also, thanks Scoots ... that is a great tut!
  • StormtrixStormtrix Member Posts: 256
    xyloFun,
    Could this be something that you're looking for?
    just threw this together -

    http://gamesalad.com/game/7940

    if it is, just let me know and i'll send it to you since the GS website isn't allowing downloadable projects yet.
  • xyloFUNxyloFUN Member Posts: 1,593
    Hey Stormtrix,
    yes, that is heading in the right direction!

    Basically, I have observed children wanting to "slide" rather than to push a button.
    Sliding is quite easy to do but I want the motion to snap if it reaches the center!

    How ever, there has to be an easy way to slide the actor again.

    I am happy to see that snapping is possible and I really love the way you have done this because that is very useful for something else I am working on as well.

    How did you do that Mr. Stromtrix?
  • StormtrixStormtrix Member Posts: 256
    hmm,
    Thinking about that one with the sliding..

    in mine the gray actor has 2 change attributes to a circlex and y. then a little 4x4 invisible actor in it.
    when circle collides with the 4x4 then constrain attribute to the circlex and y.
    what's your email address and i'll send ya the project.
  • xyloFUNxyloFUN Member Posts: 1,593
    Thanks,
    If I can dissect it, I could include it with the piano which will be amazing when I'm done with it!

    littlecomposers ... atgmailcom

    Basically, my plan is to, once more, just use a scene change because of the way the lessons can be played. Any other way would be too complex for me.

    Thanks in advance :)
Sign In or Register to comment.