GameSalad

Scroll Screen with Finger Touch/Swipe

My scene is at a larger width than the device play area. I want to be able to see the objects outside the play area by using touch to scroll to the right then scroll back left.

Any suggestions?

Comments

  • Braydon_SFXBraydon_SFX Posts: 8,958Member, Sous Chef, PRO, Bowlboy Sidekick GameSalad Employee
    Armelline said:

    but that is the only way you can get to those scene attributes, for now

    only way you can get to those scene attributes, for now

    get to those scene attributes, for now

    for now

    ...oh please god yes.
    Genius. It would be extremely helpful!
  • 11XIndustries11XIndustries Posts: 28Member, PRO
    I am fairly new to the building platform of Gamesalad. I have the basics down, but understanding this action is difficult for me. Can anyone go into detail about it with step-by-step examples? Any help is greatly appreciated.
  • colandercolander Posts: 1,607Member
    I there is an instructional video for this which will show you how to do what CodeMonkey said. Search here and on Google for "swipe menu" or "scrollable menu", I think it was by tshirtbooth.
  • 11XIndustries11XIndustries Posts: 28Member, PRO
    Instead of mouse button, can I use touch, touch 1, X? I followed tshirtbooths tutorial, and it did not work. I used touch. This will be for the iphone. There is no keyboard. What did I do wrong?

  • CodeMonkeyCodeMonkey Posts: 1,803Head Chef, Member, PRO
    use mouse button. it is always the same as touch 1, even on the iOS devices, but does not require the actor to cover the whole screen for some rule condition to catch the event for touch pressed.
  • jonmulcahyjonmulcahy Posts: 10,373Member, Sous Chef, PRO
    Armelline said:

    but that is the only way you can get to those scene attributes, for now

    only way you can get to those scene attributes, for now

    get to those scene attributes, for now

    for now

    ...oh please god yes.

    this would be incredible!
  • TouchiMediaTouchiMedia Posts: 154Member
    edited January 2014
    I can get the camera to move with touch by Codemonkey's method but it goes off the scenes limits, what's best method to keep the camera constrained within scene x , y? But still move around…

    Think I figured it out, basically when scene camera origin x greater then scene width , constrain scene camera to scene width. Or something ;)
  • CodeMonkeyCodeMonkey Posts: 1,803Head Chef, Member, PRO
    in your constrains use max(0,min(sceneWidth-cameraWidth,TheExpressionYouHaveNow))
    Similar for the height.

    This will make sure with the max(0,X) it will take the larger value of 0 or X, where X is the value for...
    min(sceneWidth-cameraWidth,Y) which takes the smaller of the 2 values.
    SceneWidth-cameraWidth will be the furthest point to the right the camera origin can go.
  • TouchiMediaTouchiMedia Posts: 154Member
    edited January 2014
    Thanks CodeMonkey, I'll do some further testing.

    Last night I thought I had it , but ended up being kind of glitchy (not moving camera but getting to scenes edge)

    I will go back and look at your suggestion and try to implement that.
  • TouchiMediaTouchiMedia Posts: 154Member
    edited January 2014

    in your constrains use max(0,min(sceneWidth-cameraWidth,TheExpressionYouHaveNow))
    Similar for the height.

    This will make sure with the max(0,X) it will take the larger value of 0 or X, where X is the value for...
    min(sceneWidth-cameraWidth,Y) which takes the smaller of the 2 values.
    SceneWidth-cameraWidth will be the furthest point to the right the camera origin can go.

    Well I tried it and isn't scrolling, here is the code for this part -- note, before this using your previous method , It scrolls but with no limit , now nothing at all-

    max(0,min( scene.Size.Width - scene.Camera.Size.Width ,self.CameraOriginX+( self.CurrentMouseX - game.Mouse.Position.X ))

    -edit- maybe missing a parenthesis.. added a third parenthesis at end still nothing - think it was formatting issue, some reason one of the variables was acting as text?

    -EDIT#2- GOT IT! wwahoooo.. Thanks a bunch, this worked for moving X and constraining to scene size, thanks Codemonkey.. below is final code for X:

    max(0,min( scene.Size.Width - scene.Camera.Size.Width , self.CameraOriginX +( self.CurrentMouseX - game.Mouse.Position.X )))

    *** my self.currentmousex should probably be renamed to self.mouseoriginalX to be more clear

    Wow awesome. Appreciate it !
  • TouchiMediaTouchiMedia Posts: 154Member
    edited January 2014


    Normally I would also wrap all the constrains in another rule that does not kick in until the distance between the stored mouse position and the current mouse position is greater than 5 so it doesn't get activated until you swipe far enough and not when you are pushing UI buttons.

    Sorry but must ask one more thing before I will finally have everything set.. Having trouble on this part, about not having camera move with subtle mouse/touch movements--for example, clicking a HUD Button.

    Right now, I am setting my original camera / x,y attributes when mouse button is down rule. Then I do the constrain camera stuff that is discussed above. It scrolls when you touch and drag until edge of scene, fine. All good.

    I been trying combinations of setting a new attribute self.swipedistance. I set the swipedistance attribute to abs(game.mouse.positionX - self.mouseoriginalX) - Then create rule (if self.swipedistance > 5) , constrain the camera(blah , blah).

    But problem is there's no delay of setting the originalX,Y vs mouseX,Y …

    And so I tried doing time delays like 55

    --Well I just tried changing time to every .01 seconds and that makes it better but feels 'choppy' cause of the update time I'm guessing

    Thanks for any help or input!
  • CodeMonkeyCodeMonkey Posts: 1,803Head Chef, Member, PRO
    if you are going to make an attribute I suggest it not be one you modify.

    So something like self.swipeThreshold and have it set to 5.
    Then the rule around the constrains but inside the touch/mouse pressed event condition and after the setting of the stored camera origin and mouse values:

    If self.swipeThreshold < magnitude(self.mouseStoredX-game.mouse.Position.X, self.mouseStoredY-game.mouse.Position.Y)
  • Raikiri91Raikiri91 Posts: 1Member

    I am trying to get my entire scene to scroll. I am very new to gamesalad. Is there any way someone can break this down even further because I am having difficulty comprehending it and this is the only thread I could find on the topic. Any help would be greatly appreciated.

Sign In or Register to comment.