Heya, Casho my boy. I feel sorry for ya, kid. Nobody seems to want to help you out. Well, me and Johnny.jpg got yer back.
Check it, yo:
How To Run
, starring Johnny.jpg:
See Johnny. See Johnny run. Run, Johnny, run! But how does Johnny run? We put the default Platform movement on him, but it's not enough. He just sorta slides back and forth. So we make a new animation for him called "Running" and fill it with some running frames. Check it out in the Animator Bar.
But there's a problem... he doesn't know how to move his feet when he runs! Johnny's not too bright. We have to tell him when to move his feet, like so:
Event 1 triggers when you have the right key down. It tells Johnny to which angle to face, and to switch to his Running animation. But we don't want any interference from the left control key, so we put in an inverted
trigger for "Move Left is down." We also only want Johnny to face the angle and switch to his animation only once
when we push right, so we add the System trigger "Trigger once." This keeps him from setting his animation to Running every cycle (which means you would only ever see the first frame of the animation).
Next, we set it up so that when there are no movement controls pressed, Johnny goes back to standing still:
Easy enough. At this point though, you may be wondering why we're using "Control is down" and "Trigger once" instead of just "On control pressed." Basically, it's because game players are sloppy! They mash the keys around when they're playing, so sometimes both left and right is pressed at the same time. This causes problems, like having poor Johnny go moonwalking around the screen. To compensate for this we put in the inverted controls to keep actions from happening on sloppy key presses, like so:
RIGHT DOWN, LEFT NOT DOWN - Run right
LEFT DOWN, RIGHT NOT DOWN - Run left
RIGHT NOT DOWN, LEFT NOT DOWN - Stop running
But there's one key combo left that we have to compensate for to refine our controls:
RIGHT DOWN, LEFT DOWN - Stop running
But the way the default Platform movement is set up, it's a bit tricky to do this. When you have both keys down, Johnny still wants to run in whatever direction you pressed last. You could conceivably do this:
BUT this leads to problems. The Platform -> Stop action stops all
movement, including jumping, and even falling! Yikes! We need something that will make a smooth transition from pressing left and right that won't make Johnny grind to a halt every time the player mashes both control keys. A better way would be like so:
Now, this might seem a little weird at first, but trust me... it works pretty well. We want Johnny to ease to a stop (or into a quick turnaround) with momentum instead of grinding to an immediate halt. So we set the Platform movement to ignore
user input when both left and right are pressed. Since this only happens very briefly when someone is playing a game, the transition from right to left movement is pretty seamless.
So, what's the event right above that for? Well, if you tell Construct to start ignoring user input, then whenever someone presses both keys down Johnny will become unresponsive. We add that event to bring input back each cycle. We're using two events to serve one purpose.
So, why don't we just set up an Else event right after checking for both keys down, instead of putting the "johnnySprite -> Platform -> Is moving" event in? Well, I tried that and it didn't work, that's why. He slid around like he was on ice when I did it that way. I don't know why. All I know is that this way it works, and the Else event didn't.
Also, this isn't necessarily the best way to do this. This method of restricting controls could be a little buggy down the line if you wanted to add more complex controls. It's just to give you an idea of how you can customize the default Platform movement to suit your needs. Once you get this down I'm sure you can come up with your own method of doing things.
Anyway, I hope this helps.
Don't steal my tiles, or Johnny will bust your ass.