Walking object only 1 subimage appearing
#1
Posted 03 May 2012 - 10:24 PM
STEP EVENT
if !place_free(x,y+1) then {
if x>xprevious then {image_speed = 1; sprite_index = spr_playerright_1}//moving right
if x<xprevious then {image_speed = 1; sprite_index = spr_playerleft_l}//moving left
if x=xprevious then {image_speed = 0; image_index = 0}}
else {
if x>xprevious then {
if y<yprevious then {image_speed = 1; sprite_index = spr_playerupa_1}//moving up
if y>yprevious then {image_speed = 1; sprite_index = spr_playerdowna_1}}//moving down
if x<xprevious then {
if y<yprevious then {image_speed = 1; sprite_index = spr_playerupb_1}//Moving up...
if y>yprevious then {image_speed = 1; sprite_index = spr_playerdownb_1}}//Moving down...
if x=xprevious then {image_speed = 0; image_index = 0}
LEFT ARROW KEY:
sprite_index=spr_playerleft_l
and drag and drop for speed of 2.
similar situation for the other arrow keys.
THE PROBLEM
to create the illusion of walking, each sprite has 6 subimages.
When I test the object movement with the arrow keys, only 1 subimage is showing per direction, so no walking at all, although its moving.
I can't figure out what is wrong, having no coding skills.
Thank you for taking your time to read this post.
#2
Posted 03 May 2012 - 10:35 PM
I think the "-1" for sprite subimage is the ticket...but I'm a newb, so what do I know?
PS
if x<xprevious then {image_speed = 1; sprite_index = spr_playerleft_l}//moving left
Is that playerleft_l ? as in, lowercase L...doesn't look like a 1
Edited by Daddio, 03 May 2012 - 10:37 PM.
#3
Posted 03 May 2012 - 11:09 PM
Did you try a subimage -1 and speed 1?
I think the "-1" for sprite subimage is the ticket...but I'm a newb, so what do I know?
PS
if x<xprevious then {image_speed = 1; sprite_index = spr_playerleft_l}//moving left
Is that playerleft_l ? as in, lowercase L...doesn't look like a 1
Thank you for the reply.
Yes, playerleft_l is for left, lowercase L.
Where exactly in the above code do I insert -1 for sprite subimage?
I am a real novice, unfortunately.
#4
Posted 03 May 2012 - 11:13 PM
As Image_Index. And you want the speed to be 1, not 0 (that makes it stop)
When you have a keypress event, it just keeps starting again and again at sprite frame (subimage) 1.
Putting in -1 tells it to just go ahead. Hope that helps and gets it working for you.
Edited by Daddio, 03 May 2012 - 11:14 PM.
#5
Posted 03 May 2012 - 11:14 PM
Also, try reducing the image speed from 1 to 0.5.
#6
Posted 04 May 2012 - 01:20 AM
Thank you for your help. Object is now walking fine. I am planning to use drag and drop as much as I can.EDIT
As Image_Index. And you want the speed to be 1, not 0 (that makes it stop)
When you have a keypress event, it just keeps starting again and again at sprite frame (subimage) 1.
Putting in -1 tells it to just go ahead. Hope that helps and gets it working for you.
#7
Posted 04 May 2012 - 01:26 AM
GML is your friend DnD is bad when it comes to specific stuff done!Thank you for your help. Object is now walking fine. I am planning to use drag and drop as much as I can.
EDIT
As Image_Index. And you want the speed to be 1, not 0 (that makes it stop)
When you have a keypress event, it just keeps starting again and again at sprite frame (subimage) 1.
Putting in -1 tells it to just go ahead. Hope that helps and gets it working for you.
I prefer GML, DnD is trouble some.
also GML is easy to learn!
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users











