Reputation: 448
I am creating a game where i need to be able to change the speed of the player sprite. I think the best option is to effect the sprites by gravity. To give the user the feeling of movement I want the background to move in the exact same speed just in the opposite direction.
How can i give the background a different gravity then the player sprite?
If you know about a better approach I would really appreciate your suggestions as well.
Upvotes: 1
Views: 127
Reputation: 1030
You can change the linearDamping
property of a node to change the rate that it falls. From the docs,
This property is used to simulate fluid or air friction forces on the body. The property must be a value between 0.0 and 1.0. The default value is 0.1. If the value is 0.0, no linear damping is applied to the object.
Note that linear damping will also affect the node's side-to-side movement as well.
Upvotes: 2