Touch Control

0 favourites
  • 6 posts
From the Asset Store
Supports keyboard, mouse and gamepads. Supports several gamepads at once.
  • How do i implement touch control alongside key control ? I already have a keypressed 8direction control set up on my player, but i want it to check if its on a touch device, allowing user to control by touching screen.

    I wanted it to move the play to the position the user touches (Like diablo II , click to move).

    Obviously id need to have the right animations playing.

    Anyways, here my player control with keys ... if anyone could show me an example of how to implement key and touch (using the same controls) then that wud be great :)

    note: i did wonder if i cud use transparent buttons that follow player and use the object touched command , but touch plugin doesnt support keyboard usage?

    also , i've tried using buttons as the guide states and when testing online (using mouse touch option "yes") it disables my key functions and doesnt do anything.

    Anyways heres the CAPX

    Download LodoseCapX

    Thanks in advance :)

  • use the "On Touch Start" event then use move sprite position to Touch.X (or Touch.Y) to move your main character sprite to that location

  • i've done that but it just instantly moves the play to that location , and does walk there?

    i want to make it so you gradually move towards to touch location , the method you supplied instantiates the player at the currently location instantly and without any animation.

  • if ur player is a bullet then u can change the angle to Touch.X and Touch.Y and increase speed or if it's standard platform behaviour then u can tell it to move in that direction (left or right)

  • You can use the same principle I used for the enemy in the other thread by using the bullet behaviour (as PepperedPenguin said). All you need to do is save the touched location in two variables "targetX" and "targetY" on touch, and set the angle of motion towards that position.

    If you rename your animations walk0, walk1, etc.. you can use the same formula I used for the enemy frames to handle the animations & directions in just one event. The formula returns 0-7 depending on angle, so you just set the animation to ' "walk"&formula ' and it will pick walk0-walk7 depending on angle.

    Check out the animations in Yann's example here.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Bloody awesome . Nim mate...you've been a diamond today. Thanks everyone!

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