8 Directional movement and "walking" sprite

0 favourites
  • 12 posts
From the Asset Store
Pixel Sprites ala ReactorCore - Builder Hardware - Large pack of sprites!
  • Is it possible to integrate 8-directional movement with a joystick? Like a sprite on screen joystick, not a plugged in game pad. I'm trying to get a sprite to move in 8 different directions, but no rotation. Like the sprite moves but its angle of orientation stays the same. Would a joystick work like that? Able to move a sprite in 8 different directions but keep its angle the same? Like 0 speed when not being moved, if moved at a constant speed, no acceleration and deceleration.

    Also how do you make a sprite "walk"? I have a sprite with two frames. When a sprite is moving automatically it alternates between the two frames. Is it possible to make it so when the player moves the sprite, instead of it moving automatically, the two frames alternate. Animations work for automatic movement, but not for player-controlled movement. Animation works perfectly with automated movement, but the same setup for player movement doesn't work, even though the sprite is being moved.

  • Do you have your sprite set to loop?

    Open the sprite in the editor and click on properties.

    Yes you can set most joysticks to work the same as pressing a key on the keyboard but codes for each joystick are different so if you design for a certain joystick and your users are not using that joystick you may have problems.

  • The Sprite isn't animated when standing still though. Has to be animated when moving, but not when standing still. Like if the sprite isn't moving at all, no animation.

    Also I'm new to joysticks and 8-direction movement, sorry. Not an actual joystick, but a joystick on the actual game screen. How would I code into an on-screen interactive joystick 8-direction movement? I tried 8-direction with arrow keys, on screen interactive sprites, but the angles were weird. Depending on where the code for movement was, the sprite would go at different angles or not move at all.

    So i have no idea how to integrate 8 direction movement into an onscreen interactive sprite joystick.

  • You have an animation and call it something like IDLE and another animation call it Walk.

    You set the animation to change when you press a key or do some other event.

    Both animations are under the same Sprite name so you are not changing sprites just the animation.

    The animation of WALK is set to loop so it appears to walk any time that animation is called.

    Most games use WASD for direction movements and QEZX can be used for the additional 4 angle directions.

    You could use the number pad but many tablets do not include a number pad so that is limiting the users.

    You can use two keys read as KEY IS DOWN and KEY IS DOWN to get 8 direction movement but that gets real tricky as you will get slash over as you change fingers from one key to the next.

  • The game is going to be on mobile phones though, so no arrow keys or letter keys for movement, that's why I mentioned integrating 8-direction movement with on an on-screen sprite joystick, not keyboard arrow keys or keyboard letter keys.

    Unless the only way to do 8-direction movement with an on-screen sprite joystick is with custom movement or pathfinding.

  • You could do it with a touch phone by creating a trigger sprite for each direction

    You would need 8 sprites one for each direction put in the shape of the joystick controls on screen and when that sprite is tap held it would act the same as a key press.

  • You could do it with a touch phone by creating a trigger sprite for each direction

    You would need 8 sprites one for each direction put in the shape of the joystick controls on screen and when that sprite is tap held it would act the same as a key press.

    This an on-screen joystick that I was talking about: http://s349.photobucket.com/user/MackMa ... k.jpg.html

    Where you move the circle that's on the inside and the sprite moves as you move the circle that's on the inside. Sorry if i wasn't clear before, that's my bad. So its pressing and holding the inside circle to move it around. And the direction the inside circle is being moved around determines where the sprite goes.

    But without any sort of rotation. Is it possible to integrate 8-direction, custom movement, or pathfinding, whatever works, with a joystick like that one in the image? So the sprite can be moved in 8-directions without rotating as its moved? No acceleration or deceleration. As soon as the joystick is no longer being held down, the sprite stops.

  • Ok yes it is possible and you could do it using trigger sprites as I explained above or using the X and Y coordinates of the cursor position on screen.

    You need a center position X and Y of the cursor and any movement that reduces Y would be up. Increases Y would be down and decreases X would be left and increases X would be right.

    If both X and Y are decreasing that is up left. Increasing would be down right and so forth.

    I would use the sprite triggers myself but you can do it with the cursor X and Y position.

  • Sorry I just found this, sorry to bother you with all of those questions.

    I got the 8-direction .capx here by Kyatric

    "Thu Apr 26, 2012 9:22 am

    Revision with 8dir and using only the touch object with "Use mouse input" set to yes.

    Still does the job "

    I tweaked it. I set speed to 0 when not being touched, but the object will sometimes "drift" even when the joystick isn't being touched.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Sorry I just found this, sorry to bother you with all of those questions.

    I got the 8-direction .capx here by Kyatric

    "Thu Apr 26, 2012 9:22 am

    Revision with 8dir and using only the touch object with "Use mouse input" set to yes.

    Still does the job "

    I tweaked it. I set speed to 0 when not being touched, but the object will sometimes "drift" even when the joystick isn't being touched.

  • FIxed the "Drifting", I set Max speed, acceleration, and deceleration to the same number.

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