Constraining between 2 set points.

GnomerGnomer Member Posts: 292
edited June 2012 in Working with GS (Mac)
Okay, so this had been asked before but I never saw the response I really needed.

Probably quite simple but what I want to do is constrain something between 2 points on the y axis, for example 10 and 300, and then have it constrained to 1 singular point on the x axis meaning it can only go up and down between set values but not left and right. (For example a brick breaker app with the paddle at the bottom.)

The main reason most other methods have not worked is because when you press another part of the screen with them, the paddle just appears there, whereas I would like it to move to there, to increase the difficulty of the game, because it seems a bit tacky when it just appears wherever you touch it.

Hope you guys can help, thanks in advance,
Ross.

Best Answers

  • ORBZORBZ Posts: 1,304
    edited June 2012 Accepted Answer
    Ah yes, I forgot the limits:

    Set bumpers where you don't want the paddle to go past.

    Of course this may not work as I am just shooting from the hip and haven't tested it and I'm sleepy :)

    The general idea is there though. you may have to tweak it
  • ORBZORBZ Posts: 1,304
    edited June 2012 Accepted Answer
    Also how did you compute the distance? I was mistaken to suggest the Magnitude function before as I wasn't thinking through clearly.

    just constrain y velocity to.position.y - touch.y

Answers

  • ORBZORBZ Member Posts: 1,304
    edited June 2012
    Constrain x to fixedValue

    Constrain linear velocity y to difference between self.position.y and touchY


  • GnomerGnomer Member Posts: 292
    @ORBZ Thank you :) How will this constrain the y between 2 points?
  • GnomerGnomer Member Posts: 292
    I think I put it in right, but it didn't work, any other suggestions?
  • GnomerGnomer Member Posts: 292
    Thanks, it's a bit late right now, but i'll give it a go tomorrow and let you know how it works :)
Sign In or Register to comment.