Jump to content


Photo

(platform game) walking and jumping sprite problem


  • Please log in to reply
5 replies to this topic

#1 IrockTheHouse

IrockTheHouse

    GMC Member

  • GMC Member
  • 62 posts

Posted 11 March 2012 - 06:22 AM

In my game, my main character has a standing sprite, a walking to the left sprite, a walking to the right sprite, and a jumping sprite.

My first problem:
I put these settings to my character:
key press <left> = change sprite to spr_walkleft (my movement actions are in the "keyboard <left>" event)
key press <right> = change sprite to spr_walkright (movement actions in different event)
key release <left> = change sprite to spr_stand
key release <right> = change sprite to spr_stand

With settings like this, whenever I hold the left and right key, my character walks in place. If I'm walking in place looking in the left direction and I let go of the left key, my character will move to the right but have the standing sprite while moving instead of walking to the right animation. And the same thing with opposite direction. I am confused and I would like to know how to fix this.

My second problem:
I can't figure out how to make my character have the jumping animation when jumping instead of the walking animation in the air.

Answers to these problems will be much appreciated!
  • 0

#2 DunnoMuch44

DunnoMuch44

    GMC Member

  • New Member
  • 17 posts
  • Version:GM8

Posted 11 March 2012 - 06:47 AM

i dont know how to do the jumping problem properly, but in my game i set it under key press: space, test expression to: if, vspeed = 0, change sprite into:jump, set the vertical speed to:-18, so it checks if he is on ground(vspeed=0) so he cant double jump. and then under the left/right key press events: if, vspeed= 0 NOT, to change sprite into jump, so instead of changing to right/left walking sprite he will stay as jump (or you can make a jump right/jump left sprite) if he is moving vertically (in the air) there will be a better way to do it so its best if you wait for somebody else's answer and if you would be so kind tell me how to do it when you know... the above solution is not perfect because when he reaches the top of his jump the vspeed will equal zero so it will glitch for a split second probably..

i dont quite get what you mean by your first problem, did you set the horizontal speed to 0 upon left/right key release? or did you want the character to keep moving when you release the key?

Edited by DunnoMuch44, 11 March 2012 - 06:53 AM.

  • 0

#3 IrockTheHouse

IrockTheHouse

    GMC Member

  • GMC Member
  • 62 posts

Posted 11 March 2012 - 07:10 PM

i dont know how to do the jumping problem properly, but in my game i set it under key press: space, test expression to: if, vspeed = 0, change sprite into:jump, set the vertical speed to:-18, so it checks if he is on ground(vspeed=0) so he cant double jump. and then under the left/right key press events: if, vspeed= 0 NOT, to change sprite into jump, so instead of changing to right/left walking sprite he will stay as jump (or you can make a jump right/jump left sprite) if he is moving vertically (in the air) there will be a better way to do it so its best if you wait for somebody else's answer and if you would be so kind tell me how to do it when you know... the above solution is not perfect because when he reaches the top of his jump the vspeed will equal zero so it will glitch for a split second probably..

i dont quite get what you mean by your first problem, did you set the horizontal speed to 0 upon left/right key release? or did you want the character to keep moving when you release the key?

I have a few more questions. I did what you said, and it worked for the most part, but when the character hit the ground he still had the jumping animation. I don't know what to do from here. What I want my character to do is when he hits the ground after jumping and he isn't moving to the right or left, he changes to standing position, but if he is moving to the right or left in the air, it should change to walking animation when he hits the ground. How could I do this? And I am kind of terrible at explaining things. What I meant as my first problem was that if I am walking to the right, the character has the walking right animation, but if I press the left key down without letting go of the right key, my character will walk in place to the left. But if I let go of the left key my character will proceed in going to the right, but he will have standing position instead of the animation. I hope this is a better explanation. I want to make it so if the left and right keys are held down, my character should stop moving and have standing position instead of walking in place, and if I let go of either the left or right key, it should change to walking animation.
  • 0

#4 DunnoMuch44

DunnoMuch44

    GMC Member

  • New Member
  • 17 posts
  • Version:GM8

Posted 11 March 2012 - 08:43 PM


i dont know how to do the jumping problem properly, but in my game i set it under key press: space, test expression to: if, vspeed = 0, change sprite into:jump, set the vertical speed to:-18, so it checks if he is on ground(vspeed=0) so he cant double jump. and then under the left/right key press events: if, vspeed= 0 NOT, to change sprite into jump, so instead of changing to right/left walking sprite he will stay as jump (or you can make a jump right/jump left sprite) if he is moving vertically (in the air) there will be a better way to do it so its best if you wait for somebody else's answer and if you would be so kind tell me how to do it when you know... the above solution is not perfect because when he reaches the top of his jump the vspeed will equal zero so it will glitch for a split second probably..

i dont quite get what you mean by your first problem, did you set the horizontal speed to 0 upon left/right key release? or did you want the character to keep moving when you release the key?

I have a few more questions. I did what you said, and it worked for the most part, but when the character hit the ground he still had the jumping animation. I don't know what to do from here. What I want my character to do is when he hits the ground after jumping and he isn't moving to the right or left, he changes to standing position, but if he is moving to the right or left in the air, it should change to walking animation when he hits the ground. How could I do this? And I am kind of terrible at explaining things. What I meant as my first problem was that if I am walking to the right, the character has the walking right animation, but if I press the left key down without letting go of the right key, my character will walk in place to the left. But if I let go of the left key my character will proceed in going to the right, but he will have standing position instead of the animation. I hope this is a better explanation. I want to make it so if the left and right keys are held down, my character should stop moving and have standing position instead of walking in place, and if I let go of either the left or right key, it should change to walking animation.




im sorry, but i cant be of much help i am a huge noob myself, although your movement problem seems strange because it is not happening to me.. you may however find the following useful: keyboard_check(vk_left) or vk_right, up down left etc,(place in test expression) to check if a key is currently pressed.. also, in relation to the jump problem: i have the exact same problem, when he lands he is still jumping, but i dont notice it much in my game because its fairly fast paced. also when my character lands moving he starts walking, so i dont know what your problem is.. i dont know if you are really allowed to do this but i have before: you should re-post this and see if you can get one of them smart as people to give you a hand (as its probably pretty low on the list by now or something). and if you find a solution to the jumping problem i would be interested to find out how to do it too.. sorry, i should have made it more obvious in my intial post that i dont really know what im doing, lol
  • 0

#5 IrockTheHouse

IrockTheHouse

    GMC Member

  • GMC Member
  • 62 posts

Posted 12 March 2012 - 12:18 AM



i dont know how to do the jumping problem properly, but in my game i set it under key press: space, test expression to: if, vspeed = 0, change sprite into:jump, set the vertical speed to:-18, so it checks if he is on ground(vspeed=0) so he cant double jump. and then under the left/right key press events: if, vspeed= 0 NOT, to change sprite into jump, so instead of changing to right/left walking sprite he will stay as jump (or you can make a jump right/jump left sprite) if he is moving vertically (in the air) there will be a better way to do it so its best if you wait for somebody else's answer and if you would be so kind tell me how to do it when you know... the above solution is not perfect because when he reaches the top of his jump the vspeed will equal zero so it will glitch for a split second probably..

i dont quite get what you mean by your first problem, did you set the horizontal speed to 0 upon left/right key release? or did you want the character to keep moving when you release the key?

I have a few more questions. I did what you said, and it worked for the most part, but when the character hit the ground he still had the jumping animation. I don't know what to do from here. What I want my character to do is when he hits the ground after jumping and he isn't moving to the right or left, he changes to standing position, but if he is moving to the right or left in the air, it should change to walking animation when he hits the ground. How could I do this? And I am kind of terrible at explaining things. What I meant as my first problem was that if I am walking to the right, the character has the walking right animation, but if I press the left key down without letting go of the right key, my character will walk in place to the left. But if I let go of the left key my character will proceed in going to the right, but he will have standing position instead of the animation. I hope this is a better explanation. I want to make it so if the left and right keys are held down, my character should stop moving and have standing position instead of walking in place, and if I let go of either the left or right key, it should change to walking animation.




im sorry, but i cant be of much help i am a huge noob myself, although your movement problem seems strange because it is not happening to me.. you may however find the following useful: keyboard_check(vk_left) or vk_right, up down left etc,(place in test expression) to check if a key is currently pressed.. also, in relation to the jump problem: i have the exact same problem, when he lands he is still jumping, but i dont notice it much in my game because its fairly fast paced. also when my character lands moving he starts walking, so i dont know what your problem is.. i dont know if you are really allowed to do this but i have before: you should re-post this and see if you can get one of them smart as people to give you a hand (as its probably pretty low on the list by now or something). and if you find a solution to the jumping problem i would be interested to find out how to do it too.. sorry, i should have made it more obvious in my intial post that i dont really know what im doing, lol

OH YES! I figured out both problems thanks to you. I don't need to give all the answers to my problems, since you don't have most of my problems, so here's the answer to YOUR problem:
Go to the "collision with [wall]" event and add in the action "Check Expression" and type in "keyboard_check(vk_left)" and check it as "NOT", then add in another expression under that is the same thing but checking for "vk_right" and check "NOT". Then add in the "Test Variable" action and type in "sprite_index" for the variable, and your jumping sprite as value and leave it as "equal to". Then put a "start of block" and an "end of block" and in between them put a "Change Sprite" action and put your standing sprite as the sprite it would change to. And there.
  • 0

#6 DunnoMuch44

DunnoMuch44

    GMC Member

  • New Member
  • 17 posts
  • Version:GM8

Posted 13 March 2012 - 06:40 AM




i dont know how to do the jumping problem properly, but in my game i set it under key press: space, test expression to: if, vspeed = 0, change sprite into:jump, set the vertical speed to:-18, so it checks if he is on ground(vspeed=0) so he cant double jump. and then under the left/right key press events: if, vspeed= 0 NOT, to change sprite into jump, so instead of changing to right/left walking sprite he will stay as jump (or you can make a jump right/jump left sprite) if he is moving vertically (in the air) there will be a better way to do it so its best if you wait for somebody else's answer and if you would be so kind tell me how to do it when you know... the above solution is not perfect because when he reaches the top of his jump the vspeed will equal zero so it will glitch for a split second probably..

i dont quite get what you mean by your first problem, did you set the horizontal speed to 0 upon left/right key release? or did you want the character to keep moving when you release the key?

I have a few more questions. I did what you said, and it worked for the most part, but when the character hit the ground he still had the jumping animation. I don't know what to do from here. What I want my character to do is when he hits the ground after jumping and he isn't moving to the right or left, he changes to standing position, but if he is moving to the right or left in the air, it should change to walking animation when he hits the ground. How could I do this? And I am kind of terrible at explaining things. What I meant as my first problem was that if I am walking to the right, the character has the walking right animation, but if I press the left key down without letting go of the right key, my character will walk in place to the left. But if I let go of the left key my character will proceed in going to the right, but he will have standing position instead of the animation. I hope this is a better explanation. I want to make it so if the left and right keys are held down, my character should stop moving and have standing position instead of walking in place, and if I let go of either the left or right key, it should change to walking animation.




im sorry, but i cant be of much help i am a huge noob myself, although your movement problem seems strange because it is not happening to me.. you may however find the following useful: keyboard_check(vk_left) or vk_right, up down left etc,(place in test expression) to check if a key is currently pressed.. also, in relation to the jump problem: i have the exact same problem, when he lands he is still jumping, but i dont notice it much in my game because its fairly fast paced. also when my character lands moving he starts walking, so i dont know what your problem is.. i dont know if you are really allowed to do this but i have before: you should re-post this and see if you can get one of them smart as people to give you a hand (as its probably pretty low on the list by now or something). and if you find a solution to the jumping problem i would be interested to find out how to do it too.. sorry, i should have made it more obvious in my intial post that i dont really know what im doing, lol

OH YES! I figured out both problems thanks to you. I don't need to give all the answers to my problems, since you don't have most of my problems, so here's the answer to YOUR problem:
Go to the "collision with [wall]" event and add in the action "Check Expression" and type in "keyboard_check(vk_left)" and check it as "NOT", then add in another expression under that is the same thing but checking for "vk_right" and check "NOT". Then add in the "Test Variable" action and type in "sprite_index" for the variable, and your jumping sprite as value and leave it as "equal to". Then put a "start of block" and an "end of block" and in between them put a "Change Sprite" action and put your standing sprite as the sprite it would change to. And there.



Excellent! it makes so much sense, thanks for that! :thumbsup:
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users