Touch drag and drop labyrinth

0 favourites
  • 9 posts
From the Asset Store
Now you can drop everything in your game with sound :)
  • Hi

    I am trying to develop a labyrinth game for touch devices. I have searched they forum alot and havent been able to find the help i am looking for.

    I found a great example by Yann where a circle limits anothers circles movement.

    That is the closest i have found. (Yann's example)

    I would like to be able to drag a sprite through the labyrinth. i have made a small image to help illustrate.

    <img src="https://dl.dropboxusercontent.com/u/2560922/mobiledev/tests/labexample.png" border="0">

    The problem is that i cant get my head around how to block the sprite from stopping at the wall, but still going along the wall as the circle does in yann's example.

    And make sure the sprite does not "jump" over the wall.

    Hope you can help me.

  • I made a game like this recently.

    Green Labyrinth

    Green Labyrinth Classic

    What I did was add the bullet behavior to the object, and sent the angle toward the touch x and y. It worked fairly well. Make sure that bounce off of solid is enabled though.

  • Thanks for the example yogert96

    I hadnt really though about using the bullet behavior for this.

    I made a small example.

    It works... ok i would say. it still does not feel like i am dragging the object. it more the object moving towards the touch.

    So i would still be interested if there was another example which would be more drag&drop ish... if you know what i mean.

    Another thing. when i use the bullet behavior it seems to bounce alot on the walls, which makes it flikker alot.

    .capx

  • If you change the Speed Event to the Angle Event your sprite will move better.

    Something like this:

    Is In Touch=>|Set Speed to=> <<Something>>

                          |PlayerObj=>Set angle toward X= round(lerp(self.X, Target.X, 2))                                       

                                                                         Y= round(lerp(self.Y, Target.Y, 2))

    You can add dt to the thir value as you did.

    If you add Solid behavior to your moving Object and add Solid to the collison object for the walls it should collide.

    (As long as you enable Bounce off solid on the bullet properties of course.)

    This movement works for me.

    And, by the way, if you find a better movement method tell me :D

  • You mean something like this: .cpax ?

    you are right the angle change makes movement better. I can still keep the speed lerp as well though.

    But it does not fix the "flikker". If you e.g. move the ball to the "Y" shaped corner, you can actually get it to jump the wall because it "flikkers" so much.

  • In you capx I see the same code you posted in your first capx.

    I'm installing Dropbox in this machine since my other blowed up on me.

    What i mean is that in X an Y expresions of "Set angle toward" you could put:

    X: lerp(Self.X, Touch.X, dt*0.5)

    Y: lerp(Self.y, Touch.y, dt*0.5)

    Play with dt until you have something less jumpy.

    Also you can use this to stop the object at the touch position (your finger or the mouse's cursor):

    (As a subevent of "Is in touch")

       System|>Compare two values|>distance(Player.X, Player.Y, Touch.X, Touch.Y)<=10 = Set Bullet speed to 0

    Play with that 10 to match your desired offset. It helped me overcome shakiness when the player reach the destination point.

    About the sprite trespassing your walls. I don't see it happening in my example.

    My only difference is that my wall objects have always the same or more width. And i have "Pixel Rounding" on. But i doubt this cause issues on collisions.

  • Sorry, i saved the file in the wrong location :-/ it should show the changes now in the link.

    I'll try to play around with what you wrote and see what i come up with.

    A second though, just throwing out an idea. What if you were to look at it from the opposite direction. Instead of telling the ball where it cant go, could you limit it to only move on top of sprites or something down that alley.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Love and behold just as you don't know what to do... you stumble upon one of the new features in Construct 2. Scirra i love you :-)

    Try this out for size... Touch labyrinth

    Using the new Line-of-sight behavior.

    It does exactly what i was looking for.

    On a side note. Fun story.. I actually knew about the new line-of-sight behavior, but I didnt think of it.

    Until I was trying to get more rep on the website and was going through the manuals to get some more reputation <img src="smileys/smiley9.gif" border="0" align="middle"> So dont say the badge system aint good for something <img src="smileys/smiley17.gif" border="0" align="middle"> <img src="smileys/smiley32.gif" border="0" align="middle">

  • hey, you're technique is great! i was trying to achieve the exact same thing as you were. i modified it so that it doesn't overlap the walls. is there any way to make the object slide along the walls, instead of freezing when it hits a wall? here's the capx

    dropbox.com/s/25m5ro22cfjydh8/lab2examplemodified.capx

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)