How would you make 2048 style swiping?
So lets say I have an actor in the scene. (this is all theoretical my real project is very different but uses this concept) Let's say I want to make it so that when a person swipes up, the actor moves up say 10 degrees, swipe right move right 10 degrees, left, down, you get the picture.
I saw GSHelper's video on swiping here:
But that seems to be dependent on the release of the swipe, which if you look at a game like 2048, the second it registers that you have placed your finger on the screen, and moved it at all to the right, whether you lifted your finger off the screen or not, the game shifts the blocks right, left, and so on. It's not dependent on the player removing their finger from the screen. Would this be possible, to make a swiping system that when it registers you have swiped right, it activates say a "right" boolean attribute to true, which in the actor would cause what you want to happen when the right attribute is true.
I also could see this maybe being a little sensitive, like if you swipe at all up or down when trying to go right maybe it would confuse the system and GS would pick the undesired one. So would there be away to set the specific amount of distance you want to be required in any direction before it registers?
This is kind of complicated, but I do hope this is the type of thing that has already been solved, if so, please link me. If not, I'd love to hear what you have to say.
Thanks
TJ
Comments
PS Built in Swipe functionality is a MUST for gamesalad.
You can try doing when touch is pressed to see the start X and Y but instead of touch is released just put in a timer after .25s (or whatever) in the touch is pressed rule. Untested, but think it could work
Well, I figured out, like I said in the original post, my goal was to make the action that follows a swipe dependent on an attribute being true. So if I wanted an actor to move left when I swiped left, my goal was to make the swipe left cause a LEFT attribute to be true, and when the LEFT attribute is true the actor moves left a certain amount. I also did along with this work out how to make the swiping non dependent on the release of a touch.
I have attributes touchX, touchY, releaseX, releaseY (I just left them release), differenceX, differenceY, absX, absY, DOWN, LEFT, RIGHT.
(It should be noted that I have only the desire to make down, left, and right swipes work, I have no use for Up, a few things would have to be adjusted to make up work, but it would follow the same basic principle.)
So heres the code,
I have an actor called Swipe Button, expanded to be underlying the whole scene, in that actor we have:
And there you have it. After this I placed a bunch of copies of actors with display texts in them, each displaying each of the attributes, so I could monitor them. Surprisingly, this is the first time I've just gone out on a whim and just made something on the way that I thought it could work, and it just simply worked the first time I opened it up in the prototyper. I was stoked. Anyway, I hope this helps someone, and I would love to hear if there is any redundancy I can remove to clean it up a little, and if theres anything else I could to do improve it.
Thanks,
TJ
PS, if anyone wants to thow this over to T shirt booth/GShelper, maybe he can make an updated video on this, maybe as an alternate method for swiping.
Oh and Im gonna repeat myself in saying that this really should become a built in feature in gamesalad.
Thanks again,
TJ
Hate to bring this thread back from the dead but I have a problem where when I start the test screen the actors just wont accept any swiping input for like 4-5 seconds or so. Im swiping in all directions and nothing happens and then after a few seconds it starts working. Is this just the tester being slow?? How can I prevent this?
Also, I have it set up so that when a swipe is happening, it activates a self attribute in the actor that the swipe is currently affecting, and that self attribute stays on forever. Once that attribute is activated the actor is supposed to move to some coordinates at a speed of 500 (run to completion) and then after 0.5 seconds it is supposed to move to another set of coordinates at a speed of 2000. But the problem is sometimes the actor will just go off the screen to the left or the right (which ever direction it of the coordinates it was supposed to go to), and then either comes back to the coordinates it was supposed to go to in the first place really quickly then performs going to the second set of coordinates at the 2000 speed (this is more common), or it goes off screen to the left or the right again in the direction of the coordinates its moving to and a full second later comes back moving in the opposite direction and goes off screen on the other side and never comes back.
Now because this happens on occasion under different circumstances every time, this leads me to believe that its not an actual error in the code but rather Gamesalad just running weirdly sometimes. But I'd really like to figure this out.
Anyone have any solutions to this or have similar oddities happen in their games?