Need Help Please!!! Swipe right to move left!?

borabora Member, PRO Posts: 45
edited December 2012 in Working with GS (Mac)
Hi,

i made a gallery with a width of over 2000 px and i want move the cam like i scroll the background.
How can i do that?

I have an Actor that controll the cam whit this rule:

Touch is pressed
(Change Attribute) self.offset to self.Position.Y-game.Mouse.Position.Y
(Constrain Attribute) self.Position.Y to game.Mouse.Position.Y+self.offset

That works fine but not inverted (offset is an attribute (real))


Thanks!

Comments

  • MobileRocketGamesMobileRocketGames Member Posts: 128
    edited December 2012
    It's too bad the templates are down. I used a template to deconstruct this very system to use in a game I'm working on. I later decided to go a different route and didnt use that system.

    Heres a tip, its more complicated than you think it is, because you have to mimic the effect that happens when you swipe and then release the screen (the screens momentum keeps it moving).

    UNLESS, you don't care and you just want the screen to stop immediately after the players finger loses contact with the screen.

    In which case, there are several ways you can do that.
    I have a easier suggestion though.

    Just have the right and left sides of the screen act as a movement button. When the left side is pressed, have the screen move to the left and when the right side is pressed have it move to the right.

    To do this:
    Create a box, throw it in the center of the scene, make its alpha 0 and have it control the camera.

    Inside that actor create a rule (all):
    When game.Touch1.X > (half screen width) and game.touchCount > 1 and self.Position.X < 1800 (or wherever your image ends minus half the screen width):
      Constrain attribute self.linearVelocity.X to 50 (or whatever speed you want)
    create a duplicate of this rule for the inverse

    When game.Touch1.X < (half screen width) and game.touchCount > 1 and self.Position.X > (half the screen width):
      Constrain attribute self.linearVelocity.X to -50 (or whatever speed you want)

    When you press the screen and the location you press is less than half the screen width, it will move that box to the left, if its higher than half the screen width it will move to the right. That box is invisible, and controls the camera, so the camera will follow it and no one will know its there.
  • hippikonhippikon Member Posts: 30
    Try this;
    Inside the actor create real attribute call positionOffset

    Touch is pressed
    (Change Attribute) self.offset to self.Position.Y-game.Mouse.Position.Y

    (Change attribute) self.positionOffset to
    game.Mouse.Position.Y

    (Constrain Attribute) self.Position.Y to ((game.Mouse.Position.Y-self.postionOffse)*-1)+self.offset+self.positionOffset

    Tell if is it you want.




    Thanks!
  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,881
  • borabora Member, PRO Posts: 45
    Thanks to MobileRocketGames and RThurman and a special thanks to hippikon!!!

    hippikon this is exactly what i want!

    Thanl You very much :)>-
Sign In or Register to comment.