How to make a sprite walk right and left on mobile?

delifood1

  • *
  • Posts: 14
I’ve been trying to figure this out for a while. I’ve gotten my character to jump by pressing the screen. But I can’t figure out how to make it move left and right in the direction I want.

Electric Fruit

  • *
  • Posts: 115
Hi

I think we're going to need a bit more info before we can help. Can you be more specific on what your trying to do or possibly post some of your code.

delifood1

  • *
  • Posts: 14
Sorry..

Im using stencyl version 4.01

Andriod Target: Api 26 8.0.0 Oreo

I’m attempting to make a platformer with left and right movement. And im looking for the best code to do that with. The traditional code that comes with the run and jump kit only support computer keyboard movement, and I’m looking to convert those movements into touch controls when holding on screen.

JeffreyDriver

  • *
  • Posts: 2168
Use the mouse blocks. Check if the mouse is down (screen is touched) on the left or right side.
Current Projects:
The Grand Grimoire Chronicles Episode 1 now on Kongregate!.
I always appreciate useful feedback. Thank you.
www.jeffreydriver.co.uk

delifood1

  • *
  • Posts: 14
Use the mouse blocks. Check if the mouse is down (screen is touched) on the left or right side.

I tried this with no luck, it only lets me move in one direction when screen touched. I need to be able to move left or right depending on where it's touched in relation to the sprite position.

delifood1

  • *
  • Posts: 14
All im looking to do is to mimic a mario platformer type movement (left, right, jump) for a mobile game. I found a way to do a point and click but the movement doesn't feel natural because the sprite just goes wherever I clicked. I'm new to this and feel as if it's a easy fix. I would really appreciate the help!


JeffreyDriver

  • *
  • Posts: 2168
Use the mouse blocks. Check if the mouse is down (screen is touched) on the left or right side.

I tried this with no luck, it only lets me move in one direction when screen touched. I need to be able to move left or right depending on where it's touched in relation to the sprite position.

Instead of using the screen coordinates just check if it's pressed to the left or right of the actor. (Is the x value of the mouse press less or more than the x centre of the actor)
Current Projects:
The Grand Grimoire Chronicles Episode 1 now on Kongregate!.
I always appreciate useful feedback. Thank you.
www.jeffreydriver.co.uk

corbanwolf

  • Posts: 165
You can also have virtual joystick on your screen. Go to setting and go to mobile