How to Move an object up and down with touch?

0 favourites
  • 8 posts
From the Asset Store
This is a code so you can see the same skin on all screens (peers). Each peer gets a skin, in addition to 4 directions t
  • Hello,

    I'm a doubt about touch. How do I touch up when an object make it move X px up and down when playing make him move X px down?

    <img src="" border="0" />

    Can anyone help me?

  • I don't know if i get your problem.

    Buut I think you could do this

    Every tick > set objects position to touch.x+*number* and touch.y+*number*

    This will set the object where you touch but slightly lower(plus y) and slightly to Left(plus X)

    Hope this helps

  • Easiest way would be to install the most used third-party plugin MoveTo.

    All you'd have to do is to compare touch.y with sprite.y and set MoveTo destination accordingly.

    Another way is to cretae a custom movement that does exactly the same.

    And yet another way is to create this movement in events by using lerp and dt to make the transition between SpriteOldY and SpriteDestination visible.

  • Thanks, guys.

    I doing using the plugin "MoveTo". But it's strange, whenever he (the circle =P) moves to top or down he "walking to back", any idea how to fix this?

    <img src="" border="0" />

    The .capx url (

    Thank you again!

  • Use lerp :D

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I don't know what's lerp! @

  • So... I'm trying to use 'derp' now, but, I don't understanding their final parameter.

    The circle don't move to a new position, he is "jumping" to a new position. How I can fix this? Somebody know?

    <img src="" border="0" />


    Thank you   <img src="smileys/smiley1.gif" border="0" align="middle" />

  • LERP(start, end, alpha)

    There is a tutorial on LERP in the tutorials section. It's a fantastic place to learn many of the in's and out of C2. Especially to help new users to get there feet running and best of all. it's immediatly there adn doesn't require any waiting for a reply.

    Anyways, LERP

    Start, this is the original start value of a number range.

    End, this is the last value in the number range.

    Alpha which is a 0.0 to 1.0 value. Represents the %0 to %100 of the two numbers. So here is a couple of examples.

    50 = lerp(0, 100, 0.5)

    440= lerp(200, 1000, 0.3) ie %30

    However, often LERP is used for the fantastic use of acceleration to deceleration of movement over distance.


    Player.Y = lerp(player.y, touch.y, 0.1)

    This results that per tick the player will move 10% of the distance between the players current distance and the target distances. So the farther the player is away. the faster the players moves. However as the player get's closer the player will slow down do to the fact that %10 becomes smaller per tick.

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