Scroll Screen with Finger Touch/Swipe
11XIndustries
Member, PRO Posts: 28
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?
Any suggestions?
Comments
Also when you see the mouse button down event, store the camera origin X and Y in a different set of attributes. You'll need to unlock an actor instance to access those. (I generally don't recommend unlocking instances, but that is the only way you can get to those scene attributes, for now) In that unlocked instance, after storing all of values for reference points, you can now use constrain on the camera origin X and Y and constrain them to the camera origin stored plus the offset based on the difference between the stored mouse position and the current mouse position.
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.
Contact me for custom work - Expert GS developer with 15 years of GS experience - Skype: armelline.support
My GameSalad Academy Courses! ◦ Check out my quality templates! ◦ Add me on Skype: braydon_sfx
Universal Binary Template - Universal Binary Template Instructions Rev 4 (Short) - Custom Score Display Template
this would be incredible!
Send and Receive Data using your own Server Tutorial! | Vote for A Long Way Home on Steam Greenlight! | Ten Years Left
Think I figured it out, basically when scene camera origin x greater then scene width , constrain scene camera to scene width. Or something
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.
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.
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 !
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!
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)
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.
Hey guys, this took me so long to figure out. The Mouse does not work for touch scrolling. What you need to do is instead of selecting Mouse, you have to change it to Touch OUTSIDE. But everything tshirtbooth said, works outside of using the Mouse. If you don't know what I'm referring to, here is the link.
http://learn.gamesalad.com/course-status/
There is honestly so much information missing for Windows, for little things like this and answers posted that are completely incorrect.
But I got this to work. Also be sure that if your scrolling is on the Y access (Up and Down) not X (Left to Right) change it accordingly.
So once again, follow the tut' from tshirtbooth. Change all Mouse actions to Touch Outside and ensure if you are attempting to scroll up and down change the axis to Y instead of X.