Joystick for moving a sprite

0 favourites
From the Asset Store
A smart joystick plugin, perfect for all mobile games.
  • I was reading about different kinds of joysticks in Construct 2. In the game I'm making the joystick moves the character in 8 different directions. The joystick doesn't need another circle inside of it. I looked at different tutorials but am not sure which one would work best. it has to be continuous movement. Like a person can keep moving the character, so it has to go from direction to direction without going back to the middle before the player can move it again.

    It's a fixed joystick. There is no jumping, it's just moving a sprite around. I know some joysticks move, others have circles inside of them that move. this doesn't need any of that. as long as they can touch it and move the sprite in 8 directions, it works.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Imo having even a small circle inside a larger one helps the user visually. Someone helped me with this before, having a small circle inside a larger one. And it was constant and fluid.

    The smaller circle did not need to recenter to move again.

    I'll see if i still have that capx later today. In the meantime, do a forum search for 'thumbstick' and browse through the posts.

  • Phoenixbowman

    This is one of my thumbsticks, and the easiest to follow:

    Again, it seems like a lot, but it does move pretty fluidly. And if you'd like, you can set the thumbstick (the small inner circle) at 0% opacity so it won't be seen.

    There is a way to do this just with a touch input and without a thumbstick, but imo users tend to slide their thumb around the screen, which makes them have to stop, lift their thumb and bring it back down to the corner. This way it gives them a point of reference for their thumb.

  • Oh wow thank you, thank you so much. Is it possible to take out the angle so the Sprite doesn't rotate?

  • So you don't want the sprite to turn at all?

  • The sprite is a person, so no, can't be turning at all, has to be upright. Would I just remove the angle part of the code? Say the Sprite's angle is 180 degrees, that has to stay the same and can't change, sorry.

    Imagine a person walking at a constant speed. Going from 0 and when the player moves the joystick, the sprite goes from 0 to max speed instantly, and when they release the joystick, the sprite stops, no slowing down.

  • Its been a while since i messed with that, but i think you would remove the action rotate 225....

  • Sorry, what's a Local Static Variable? I was looking over the code and I noticed something called local static variable.

    Is a joystick a good idea for a sprite that can't rotate? like the sprite's orientation is 0 degrees, and can't rotate. Imagine a person standing upright and moving at a constant speed in 8 directions depending on where the joystick is being moved.

    Like no acceleration, move joystick, go from 0 to x speed, release joystick, stop. Or would arrow keys work better?

  • It's basically a person running around. So there is no acceleration, it's one speed and the sprite can move 8 different directions. Like move at one speed in one of 8 directions. Like the sprite is standing still. When the sprite starts moving, it moves at one constant speed, no accelerating or decelerating.

  • Sorry I'm still not sure how to do this. The Sprite has one speed and can move in 8 different directions. Moving the joystick will make the sprite move in one of 8 directions at a constant speed, no acceleration or deceleration.

    I see the code but don't know what a Local Variable is.

  • Have you looked at 8 direction behaviour?

  • I looked into the 8 direction behavior, but the angles were weird when I used arrow keys, like click arrow key, move in this direction. Depending on what direction i had in the code the sprite would move at different angles.

    These are not the actual numbers, just as an example:

    Like Touch Left at -90 at 100 speed, then touch right at 180 degrees at 100 speed. the sprite would move left with Touch Left and Up with 180 degrees.

    If I then put Touch Right above Touch left in the code, the sprite would move at different angles.

    How would I integrate the 8 directions into your code for a Joystick?

  • In that case i think you could just use my example. But i'd have to look at it to get the rotate out of there.

    I'll look at it today.

  • The only game I've ever done involved tapping sprites, it didn't involve the player actually moving a sprite, that's why I have so many questions.

  • When you can please let me know about integrating 8-directional movement, without the Sprite's angle of orientation changing, into a joystick. The only game I've done involved tapping sprites so I have no idea how to do it with a joystick and 8-directions, sorry.

    Unless Joystick cant use 8-directions, and arrow keys are the only way to go for 8-directions?

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