| 2224 | } |
| 2225 | |
| 2226 | void EETest::demo1Create() { |
| 2227 | createJointAndBody(); |
| 2228 | |
| 2229 | Shape::resetShapeIdCounter(); |
| 2230 | |
| 2231 | mSpace = Physics::Space::New(); |
| 2232 | mSpace->setGravity( cVectNew( 0, 100 ) ); |
| 2233 | mSpace->setSleepTimeThreshold( 0.5f ); |
| 2234 | |
| 2235 | Body *body, *staticBody = mSpace->getStaticBody(); |
| 2236 | Shape* shape; |
| 2237 | |
| 2238 | shape = mSpace->addShape( |
| 2239 | ShapeSegment::New( staticBody, cVectNew( 0, mWindow->getHeight() ), |
| 2240 | cVectNew( mWindow->getWidth(), mWindow->getHeight() ), 0.0f ) ); |
| 2241 | shape->setE( 1.0f ); |
| 2242 | shape->setU( 1.0f ); |
| 2243 | shape->setLayers( NOT_GRABABLE_MASK ); |
| 2244 | |
| 2245 | shape = mSpace->addShape( |
| 2246 | ShapeSegment::New( staticBody, cVectNew( mWindow->getWidth(), 0 ), |
| 2247 | cVectNew( mWindow->getWidth(), mWindow->getHeight() ), 0.0f ) ); |
| 2248 | shape->setE( 1.0f ); |
| 2249 | shape->setU( 1.0f ); |
| 2250 | shape->setLayers( NOT_GRABABLE_MASK ); |
| 2251 | |
| 2252 | shape = mSpace->addShape( ShapeSegment::New( staticBody, cVectNew( 0, 0 ), |
| 2253 | cVectNew( 0, mWindow->getHeight() ), 0.0f ) ); |
| 2254 | shape->setE( 1.0f ); |
| 2255 | shape->setU( 1.0f ); |
| 2256 | shape->setLayers( NOT_GRABABLE_MASK ); |
| 2257 | |
| 2258 | shape = mSpace->addShape( ShapeSegment::New( staticBody, cVectNew( 0, 0 ), |
| 2259 | cVectNew( mWindow->getWidth(), 0 ), 0.0f ) ); |
| 2260 | shape->setE( 1.0f ); |
| 2261 | shape->setU( 1.0f ); |
| 2262 | shape->setLayers( NOT_GRABABLE_MASK ); |
| 2263 | |
| 2264 | Float hw = mWindow->getWidth() / 2; |
| 2265 | |
| 2266 | for ( int i = 0; i < 14; i++ ) { |
| 2267 | for ( int j = 0; j <= i; j++ ) { |
| 2268 | body = mSpace->addBody( Body::New( 1.0f, Moment::forBox( 1.0f, 30.0f, 30.0f ) ) ); |
| 2269 | body->setPos( cVectNew( hw + j * 32 - i * 16, 100 + i * 32 ) ); |
| 2270 | |
| 2271 | // shape = mSpace->AddShape( ShapePolySprite::New( body, 30.f, 30.f, mBoxSprite ) ); |
| 2272 | shape = mSpace->addShape( ShapePoly::New( body, 30.f, 30.f ) ); |
| 2273 | shape->setE( 0.0f ); |
| 2274 | shape->setU( 0.8f ); |
| 2275 | } |
| 2276 | } |
| 2277 | |
| 2278 | cpFloat radius = 15.0f; |
| 2279 | |
| 2280 | body = |
| 2281 | mSpace->addBody( Body::New( 10.0f, Moment::forCircle( 10.0f, 0.0f, radius, cVectZero ) ) ); |
| 2282 | body->setPos( cVectNew( hw, mWindow->getHeight() - radius - 5 ) ); |
| 2283 |
nothing calls this directly
no test coverage detected