About the Touch object for the Mobiles and Tablets.

0 favourites
  • 10 posts
From the Asset Store
This is a single chapter from the "Construct Starter Kit Collection". It is the Student Workbook for its Workshop.
  • Is it the right procedure to make the board (a sprite that represents the player), to move right or left by using the Touch object? Here's the Event Sheet and tell me what you think (check the code within the red rectangle):

  • Looks like you are asking it to do the same thing for left and right, that won't work.

  • Is touching should be a separate evnnt and should have subevents: if Touch.X < centerX simulate left, else simulate right movement

  • To BadMario:

    I have sought for the Condition that will allow me to enter the following values: " if Touch.X < centerX" and I did not find it. I took a look in the "Size & Position" area in the "Condition" box and nothing match your instruction. Maybe you should send me a screenshot of an Event sheet with as a visual example of the code so I can properly know what to do.

    Thank you!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • WesleyDeveloper9 Use the "system: compare values" condition, allows you to evaluate 2 expressions and compare them with an equality operator ( <, >, ==, !=, >=, <= )

  • centerX is a variable you set ( you can call it something different ).

    That value would be middle of your layout. So if your layout is 800 px wide, then centerX would be 400. Then you just compare whether Touch.X is less or more than 400. If it's less then you are touching the screen on the left side, if more that is the right side and simulate left/right movement accordingly

  • To Nepeo:

    Thank you for the information, I have found the correct comparison condition.

  • To BadMario:

    I have followed your instructions to make my character move by using the "Touch" object, and I have put the following code in the Event Sheet (The code in the image below). Can you tell me if this code work:

    You also told me to create a variable called centerX and I did. I gave to the centerX variable 427 as a value, because my layout is 854 pixels wide, so 427 will be the center. Here's a picture of the variable:

  • It should only be Touch object is in touch. You should not have to touch the player sprite to move ( then you cannot see him, he will be covered by your finger )

    That way you can touch the screen anywhere and player will move left or right depending on which side of the screen you are touching.

  • To BadMario:

    Ok, I have made the modification, I put "Touch" object into "is in touch" condition. Here's an image of the modification that I have made:

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