| 2364 | } |
| 2365 | |
| 2366 | void EETest::demo2Create() { |
| 2367 | createJointAndBody(); |
| 2368 | |
| 2369 | Shape::resetShapeIdCounter(); |
| 2370 | |
| 2371 | mSpace = Physics::Space::New(); |
| 2372 | mSpace->setIterations( 10 ); |
| 2373 | mSpace->setGravity( cVectNew( 0, 100 ) ); |
| 2374 | |
| 2375 | Body* staticBody = mSpace->getStaticBody(); |
| 2376 | Shape* shape; |
| 2377 | |
| 2378 | emitterInstance.queue = 5; |
| 2379 | emitterInstance.blocked = 0; |
| 2380 | emitterInstance.position = cVectNew( mWindow->getWidth() / 2, 150 ); |
| 2381 | |
| 2382 | shape = mSpace->addShape( ShapeCircle::New( staticBody, 15.0f, emitterInstance.position ) ); |
| 2383 | shape->setSensor( 1 ); |
| 2384 | shape->setCollisionType( BLOCKING_SENSOR_TYPE ); |
| 2385 | shape->setData( &emitterInstance ); |
| 2386 | |
| 2387 | // Create our catch sensor to requeue the balls when they reach the bottom of the screen |
| 2388 | shape = mSpace->addShape( |
| 2389 | ShapeSegment::New( staticBody, cVectNew( -4000, 600 ), cVectNew( 4000, 600 ), 15.0f ) ); |
| 2390 | shape->setSensor( 1 ); |
| 2391 | shape->setCollisionType( CATCH_SENSOR_TYPE ); |
| 2392 | shape->setData( &emitterInstance ); |
| 2393 | |
| 2394 | Space::CollisionHandler handler; |
| 2395 | handler.a = BLOCKING_SENSOR_TYPE; |
| 2396 | handler.b = BALL_TYPE; |
| 2397 | handler.begin = [this]( Arbiter* arb, Space* s, void* v ) { return blockerBegin( arb, s, v ); }; |
| 2398 | handler.separate = [this]( Arbiter* arb, Space* s, void* v ) { blockerSeparate( arb, s, v ); }; |
| 2399 | mSpace->addCollisionHandler( handler ); |
| 2400 | |
| 2401 | handler.reset(); // Reset all the values and the callbacks ( set the callbacks as !IsSet() |
| 2402 | |
| 2403 | handler.a = CATCH_SENSOR_TYPE; |
| 2404 | handler.b = BALL_TYPE; |
| 2405 | handler.begin = [this]( Arbiter* arb, Physics::Space* s, void* v ) { |
| 2406 | return catcherBarBegin( arb, s, v ); |
| 2407 | }; |
| 2408 | mSpace->addCollisionHandler( handler ); |
| 2409 | } |
| 2410 | |
| 2411 | void EETest::demo2Update() { |
| 2412 | if ( !emitterInstance.blocked && emitterInstance.queue ) { |
nothing calls this directly
no test coverage detected