Log in
Search
GameML File Sharing
USERNAME: gamemladmin@gmail.com PASSWORD: gamemlsite Upload Here: https://gameml.forumotion.com/GameML-File-Sharing-h3.htmPlease add only games.Sprite drawing
4 posters
:: Game Making :: Game Maker Help :: Game Dev. Q&A :: GML help (Coding)
Page 1 of 1
Sprite drawing
I'm having a little problem with making an object draw sprites at its own position.
In the draw event I have this code.
In the draw event I have this code.
- Code:
//draw all the body parts
draw_sprite(spr_player_body,facing,x,y)
draw_sprite(spr_player_hand,facing,x,y)
draw_sprite(spr_player_gun,(point_direction(x,y,mouse_x,mouse_y))/360*22,x,y)
//draw the feet, if the player is walking draw the feet walking
if hspeed == 0
draw_sprite(spr_player_feetr,0,x,y)
if !hspeed == 0
{
if hspeed > 0
draw_sprite(spr_player_feetr,-1,x,y)
if !hspeed > 0
draw_sprite(spr_player_feetl,-1,x,y)
}
Re: Sprite drawing
Try this:
What you did, was "if !hspeed == 0", and that makes little sense. It should either be "if !(hspeed == 0)" or "if (hspeed != 0)". The position of the ! and parathesis does matter. That's why I don't like the sloppy syntax of GML, it makes everything harder -_-
ALWAYS use parenthesis around an if-statement, no matter how short it is, and ALWAYS use brackets "{" after the if-statement. It will save you so much trouble later on.
- Code:
if hspeed == 0
draw_sprite(spr_player_feetr,0,x,y)
if hspeed != 0
{
if hspeed > 0
draw_sprite(spr_player_feetr,-1,x,y)
if hspeed < 0
draw_sprite(spr_player_feetl,-1,x,y)
}
What you did, was "if !hspeed == 0", and that makes little sense. It should either be "if !(hspeed == 0)" or "if (hspeed != 0)". The position of the ! and parathesis does matter. That's why I don't like the sloppy syntax of GML, it makes everything harder -_-
ALWAYS use parenthesis around an if-statement, no matter how short it is, and ALWAYS use brackets "{" after the if-statement. It will save you so much trouble later on.
Hepolite- GameML Noob
- Posts : 23
Points : 54587
GameML Reputation : 12
Join date : 2009-06-03
Age : 31
Location : Land far, far away from the land far, far awaay
Re: Sprite drawing
Thanks for the tip, but it's still not animated. That's solved the problem of the feet disappearing when the player's not on the ground, but the feet aren't walking. Is there anything else I can try?
Re: Sprite drawing
Try this (it's basically the same thing Hepolite did):
Make sure you dont have any code that is interfering with the image_index of this object that may cause the feet to stop moving; such as image_speed = 0. And aslo make sure that these sprites are actually animated as you want them.
- Code:
if hspeed == 0
{draw_sprite(spr_player_feetr,0,x,y);}
else
{
if hspeed > 0
{draw_sprite(spr_player_feetr,-1,x,y)}
if hspeed < 0
{draw_sprite(spr_player_feetl,-1,x,y)}
}
Make sure you dont have any code that is interfering with the image_index of this object that may cause the feet to stop moving; such as image_speed = 0. And aslo make sure that these sprites are actually animated as you want them.
Re: Sprite drawing
Thanks guys but it's... still not doing what I want it to do. I don't know why it's doing this to me, and things like this always happen.
:: Game Making :: Game Maker Help :: Game Dev. Q&A :: GML help (Coding)
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum