Pages: 1
So yeah, I'm making this Zelda-like game and I'm currently trying to implement movement controls. I've gotten the basics down fairly well, but there's a couple of nuances that are really bugging me and I just can't figure them out.
Okay, first of all, I can move the main character in the four cardinal directions using a basic script.
when gf clicked forever if <Key Down Arrow Pressed> point in direction (180) move (3) stepsSimple enough and it works, the smooth movement is clearly better than just using the When Key Pressed control function.
Offline
Put a "Repeat until NOT key down arrow pressed" around "Point in direction 180, move 3 steps. That way, it will only repeat down arrow, until a new key is pressed. Do the same for all keys.
Hope that helps!
Offline
CopperHawk wrote:
Put a "Repeat until NOT key down arrow pressed" around "Point in direction 180, move 3 steps. That way, it will only repeat down arrow, until a new key is pressed. Do the same for all keys.
Hope that helps!
Thanks for the tip. It definitely makes the movement smoother, and although it stopped the overlapping it still doesn't allow you to push a different button while still holding the original direction button to change direction. The sprite would just stop...
But, that's a minor complaint. I would still like to be able to figure out how to change my characters costume change animations for movement. I think I'm going to try making a repeat forever loop inside of my other repeat forever loop.
Offline
Alright, I figured it out! Here's what I did.
when gf clicked forever if (key [down arrow] pressed) repeat until <not(key [down arrow] pressed)> point in direction [180] move (3) steps when gf clicked forever if (key [down arrow] pressed) repeat until <not(key [down arrow] pressed)> switch to costume [front1] wait (0.1) seconds switch to costume [front2] wait (0.1) secondsI don't think my scratchblocks code is too great, but these separate threads should work wonders in scratch. Implementing this code with each arrow key allowed me to fully flesh out my movement animation for a top down action adventure game.
Offline
Okay, my current predicament seems to be that my sprite's costume doesn't change fast enough. I think it might have to do with the wait .1 second loop, but I have no idea how to work around that.
Here, I'm going to post a link to my current project to show what I mean. When you press a button in any of the directions too quickly the sprite's costume just doesn't react quickly enough to the movement.
http://scratch.mit.edu/projects/ACDash/2844066
It doesn't look terrible, but it's definitely noticeable.
Offline
Pages: 1