Cocos2d-x3.3 Physics physical engine module solves the problem of Rigid Body penetration, cocos2dx3.3
Check the Code:
Void PhysicsFixedUpdate: onEnter ()
{
PhysicsDemo: onEnter ();
_ Scene-> getPhysicsWorld ()-> setDebugDrawMask (PhysicsWorld: DEBUGDRAW_ALL );
_ Scene-> getPhysicsWorld ()-> setGravity (Point: ZERO );
// Wall
Auto wall = Node: create ();
Wall-> setPhysicsBody (PhysicsBody: createEdgeBox (VisibleRect: getVisibleRect (). size, PhysicsMaterial (0.1f, 1, 0.0f )));
Wall-> setPosition (VisibleRect: center ());
This-> addChild (wall );
AddBall ();
ScheduleOnce (schedule_selector (PhysicsFixedUpdate: updateStart), 2 );
}
Void PhysicsFixedUpdate: addBall ()
{
Auto ball = Sprite: create ("Images/ball.png ");
Ball-& gt; setPosition (100,100 );
Ball-> setPhysicsBody (PhysicsBody: createCircle (ball-> getContentSize (). width/2, PhysicsMaterial (0.1f, 1, 0.0f )));
Ball-> getPhysicsBody ()-> setTag (DRAG_BODYS_TAG );
Ball-> getPhysicsBody ()-> setVelocity (Point ));
This-> addChild (ball );
}
Void PhysicsFixedUpdate: updateStart (float delta)
{
AddBall ();
// The focus is here
_ Scene-> getPhysicsWorld ()-> setAutoStep (false );
ScheduleUpdate ();
}
Void PhysicsFixedUpdate: update (float delta)
{
// Use fixed time and calculate 3 times per frame makes physics simulate more precisely.
// Here, it indicates that the first step is 3. If the fps is 1/60, the third setp is 1/180.
For (int I = 0; I <3; ++ I)
{
_ Scene-> getPhysicsWorld ()-> step (1/180. 0f );
}
}
Simulated Driving 2011 cannot create physical engine physics engine instance cocould not be created
NVIDIA PhysX physical acceleration driver 9.10.0513 For WinXP/XP-64/Vista-64/Win7/Win7-64, updates include: fixed the issue of PhysX Acceleration not working properly on Optimus PC.