Problem origin: Generally, the fixedRotation attribute of the b2Body of the player is set to true, that is, it cannot be rotated. This ensures that the player will not twist when it is subject to physical force, for example, his character model is always upright. When a player encounters a inclined object, there is only one contact point between it and the inclined surface, so there is no friction
Problem origin: Generally, the fixedRotation attribute of the b2Body of the player is set to true, that is, it cannot be rotated. This ensures that the player will not twist when it is subject to physical force, for example, his character model is always upright. When a player encounters a inclined object, there is only one contact point between it and the inclined surface, so there is no friction
Problem origin:
Generally, the fixedRotation attribute of the b2Body of the player is set to true, that is, the player cannot be rotated. This ensures that the player does not twist when it is subject to physical force, for example, his character model is always upright. When a player encounters an inclined object, there is only one contact point between it and the inclined surface, so there is no friction, which will cause distortion of the player's motion state.
- If the player's fixedRotation is set to false, it can be rotated. In this case, the friction is normal, but the player's sprite image also rotates, but sometimes it is expected that the sprite remains upright.
Solution: 1. Always fixedRotation = true,
When the player is on the slope, the player body is constructed into a polygon with the oblique edge at the bottom, and the tilt angle is the same as the slope angle. On a plane, the bottom of the body is changed to a plane.
Disadvantages: 1. unable to adapt to the slope of various angles.
2. Because b2Fixture in Box2D cannot be deformed, The b2Body object wants to change its shape. The b2Fixture object must be created and destroyed repeatedly, which is complex and inefficient.
2. When the player is on a plane, fixedRotation = true;
When the player is on the slope, fixedRotation = false; then the sprite image of the player rotates the corresponding angle according to the slope angle.
- The specific method is probably: Build a slope class inherited from CCSprite, the class members include the b2Body of the slope, the angle of the slope degree, the class method includes the creation method of the slope createInclinePlane (), the degree of the slope is obtained in this method.
- When degree is required, use getor () of degree to obtain it.