on Touch Controls

0 favourites
  • 7 posts
From the Asset Store
Supports keyboard, mouse and gamepads. Supports several gamepads at once.
  • Hi,

    Can anyone tell me how to do this:

    When I drag the sprite using touch control, the movement of the sprite must only go up and down in one place.

    thanks in advance. <img src="smileys/smiley1.gif" border="0" align="middle" />

  • Yeah. I found using the Drag and Drop behaviour works poorly when your trying to use it with setPosition() when limiting area.

    I have a thought on how you can do this

    Don't Drag and Drop your slider icon.

    Create an invisible drag and drop object over your up/down slider sprite.

    set Y position of your slider to the Y of your Drag Box.

    This will limit your slider sprite to the Y axis.

    You will also need to check for Y minimum and maximum ranges. You can do this with a heavy inline if statement or 2 extra sub events.

    slider.y = ( (drag.y < min) || (drag.y > max) ? (drag.y < min ? min : max) : drag.y )

    don't forget to reset your drag box on drop :)

    here is a tutorial. Overkill for you needs but you never know what helpful information you can find.

    scirra.com/tutorials/398/touch-stick-controllers/page-1

    Now if there is a way to limit an particular objects axis. That would be cool, but I have no idea if that exists. Still a noob here :D

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Thanks man! This was very helpful!

    Keep it up! <img src="smileys/smiley1.gif" border="0" align="middle" />

  • Actually thinking about it while walking my son to school I had another thought.

    If your using the controls for some kind of main menu or options(ie volume control). Then you don't need to prepare for multi touch input. Instead you can make it a little easier.

    Here is a sample of all 3 ways I suggested.

    dl.dropbox.com/u/14087254/lineardragsprite.capx

  • Hi again,

    I have a Problem...

    The Sprites moves in Circles, I think it's because of radius.

    How am I going to make it move not in radius but all in a square sprite (don't know the terms yet)

  • I think reading the purpose of the tutorial would help, however I also linked a capx that will serve your purpose for linear sliding of a touch event. the linking of the tutorial was only for checking out how to do drag and drop object to effect another sprite. not to literally copy command for command :D

    However, I thought of an easiest way to do only up and down sliding. I updated the capx.

    here is the link to the capx samples directly relating to what you want

    dl.dropbox.com/u/14087254/lineardragsprite.capx

    there are 3 models.

    Left: uses ontouch background object

    middle: drag and drop the slider box

    right: drag and drop a drag box that effects the moving sprite.

    choose one that serves you best :)

  • Thanks again man!

    It really worked fine!

    <img src="smileys/smiley36.gif" border="0" align="middle" />

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