Note that there are some explanatory texts on larger screens.

plurals
  1. POBall Randomly Slowing Down
    primarykey
    data
    text
    <p>Currently, I have a program that has a ball, bouncing back and forth. In order to find out how fast it's bouncing, I made this:</p> <pre><code>b2Vec2 velocity = blueCircleBody-&gt;GetLinearVelocity(); float constantSpeed = velocity.Length(); NSLog(@"%.f", constantSpeed); </code></pre> <p>This is inside a tick: function. Every second, I want to see how fast the ball is moving. As I notice in the Output window, the ball seems to slow down after few minutes.</p> <pre><code>2012-12-16 11:29:10.458 Bubble Fill V1[31623:c07] 30 2012-12-16 11:29:11.474 Bubble Fill V1[31623:c07] 30 2012-12-16 11:29:12.475 Bubble Fill V1[31623:c07] 30 2012-12-16 11:29:13.492 Bubble Fill V1[31623:c07] 24 2012-12-16 11:29:14.525 Bubble Fill V1[31623:c07] 24 </code></pre> <p>Is there a reason why the ball randomly went from 30 to 24?</p> <p>Additionally, I have another problem. If I restart the program, with all the same data, the ball is going at a different speed for unknown reason. This means that the impulse/force I use doesn't dictate how fast it's going.</p> <p>Here's some more information on the ball:</p> <pre><code> blueCircle = [CCSprite spriteWithFile:@"blueCircle.png"]; blueCircle.position = ccp(winSize.width/4, winSize.height/4); blueCircle.tag = 2; [self addChild:blueCircle]; blueCircleBodyDef.type = b2_dynamicBody; //Find a way to make the BoundingBox/GroundBox to not be affected by the Force of the Walls blueCircleBodyDef.position.Set(winSize.width/4/PTM_RATIO, winSize.height/4/PTM_RATIO); //blueCircleBodyDef.position.Set(blueCircle.position.x/PTM_RATIO, blueCircle.position.y/PTM_RATIO); blueCircleBodyDef.userData = blueCircle; blueCircleBody = world-&gt;CreateBody(&amp;blueCircleBodyDef); float blueCircleRadius = blueCircle.contentSize.width/2 * blueCircle.scale; blueCircleShape.m_radius = blueCircleRadius/PTM_RATIO; blueCircleFixtureDef.shape = &amp;blueCircleShape; blueCircleFixtureDef.density = 1.0f; blueCircleFixtureDef.friction = 0.0f; blueCircleFixtureDef.restitution = 1.0f; blueCircleBody-&gt;CreateFixture(&amp;blueCircleFixtureDef); force.Set(0, 140); //blueCircleBody -&gt;ApplyLinearImpulse(force, blueCircleBodyDef.position); //blueCircleBody-&gt;SetLinearVelocity(force); blueCircleBody-&gt;SetGravityScale(0); blueCircleBody-&gt;SetLinearVelocity(force); </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload