leonardo
Abandoned Uranium Working
Posts: 17
|
Post by leonardo on May 19, 2016 14:09:29 GMT
Once again. I'm new and i'm learning so forgive me for all my question?
Now there are a couple of problems i want to solve and i didn't find a solution anywhere:
1) Of course i can move my sprite left and right, but when i stop pressing any keys the animation of my sprite stops suddenly in an innatural position. i'd like my sprite to return in a "rest position" waiting for a key to be pressed. WAITKEY doesn't work for what i want to do. Anybody has a code for it?
2) When i jump i change sprite animation in such a way that looks like jumping, but if a press any key 0 or 1 , my sprite start running in the middle of the air. a) I don't want my sprite start running. b) I'd like to keep jumping in one direction and not have the possibility to change it. Anybody has a code for it?
Thanks in advance.
Leonardo
|
|
|
Post by andrewvanbeck on May 20, 2016 7:19:49 GMT
1) Maybe just 1 frame with the sprite skidding to a stop would be enough, then you could check the animation frame, if it's a walking animation and the player isn't moving, then set the frame to this skid frame, and if the player is already showing the skid frame, set the frame to an idle frame. It depends really how you handle animation - easiest is to just use sprites for each 'act' - but that's not ideal, either way you end up using lots of code to handle it. I would tend to just handle animation with code, and doing that means you can set specific frames, and make things fluid. I do prefer to have separate sprites for left or right movement though, that does help a lot as you only have to set the sprite image for the direction, then handle animation with code. Something like this perhaps, frame 0 is idle, frames 1 to 9 are running, and frame 10 is a skid... (Underlines added for readability)
LET DIRECTION = 0 IF LEFTKEY _LET IMAGE = 1 _LET DIRECTION = 1 ENDIF IF RIGHTKEY _LET IMAGE = 2 _LET DIRECTION = 2 ENDIF IF DIRECTION 0 _IF FRAME = 10 __LET FRAME = 0 _ELSE __IF FRAME>0 ___LET FRAME = 10
__ENDIF _ENDIF ELSE _ADD 1 TO FRAME _IF FRAME>9 __LET FRAME=1 _ENDIF ENDIF
2) Perhaps only allow walking/running if the player can't go down... like IF CANGODOWN _FALL ELSE * walk left or right on keypress ENDIF
|
|
leonardo
Abandoned Uranium Working
Posts: 17
|
Post by leonardo on May 20, 2016 7:56:32 GMT
You are a jenius.
Solution was simple. Solution 2. It works.
IF CANGODOWN ELSE LET IMAGE = "rest position" ANIMATE ENDIF
Thanks a lot.
Simple and fast.
|
|