Help with building a platformer game

I'm building a game in which there is a sprite that the player can cause to move left and right and jump. With what I have so far, the sprite is moved left and right using SKAction.moveByX and it jumps using physicsBody.applyImpulse. I want to make it so that the sprite accelerates to a certain speed when the player gives it the input and remains at that speed, rather than just instantly moving at that speed, so that it will look smoother. I also need to make it so that the sprite is only allowed to jump when it has landed and I want it not to bounce at all upon landing. Can anyone please give me some suggestions as to how to go about doing this? I am fairly new to xcode and swift (I am coding this project in swift). Also, I'm using xcode 6. Thanks very much if you help.

To fix the bouncing, you can set the physicsBody restitution to 0.


If you were using GameplayKit and the Xcode 7 beta, you might look at GKAgent or GKStateMachine to deal with your other issues, but without, you just have to handle that logic yourself. Maybe increase the X in moveByX over time, to simulate acceleration, or set the action's timing mode to EaseIn. And set a flag when the sprite collides with the ground after a jump, to show that jumping is legal again.

Help with building a platformer game
 
 
Q