Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5967287
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T19:55:20+00:00 2026-05-22T19:55:20+00:00

Am a flash game developer at present I started writing games for iphone using

  • 0

Am a flash game developer at present I started writing games for iphone using cocos 2d engine, I have implemented separate Axis theorem for collision detection which works perfect. All the polygons are drawn as follows in openGl.
Now am trying to apply gravity to this 16×16 box after many search I found this tutorial http://www.seinia.com/tutorials/Bounce/ and implemented the same in objective C.

The problem am having is after the square comes to rest it keeps bouncing up/down in fractions. I tried a lot to fix this but I couldn’t control that tiny movement.I never had such problem in flash but here the floating value is affecting the square position a lot.

Please let me know what is the write way to handle such issue , any reference URL would be helpful. Appriciated your help.Thanks!

0,16        16,16 

 ------------
|            |
|            |
|            |
|            |       
 ------------

0,0          16,0

Objective C code

if (square.points[0].y <= 0.1f) {
        velocity.vy *= -bounce;
        [square restInPeace:[Vector2D createVectorWithComponentX:velocity.vx Y:8.0f]];
        // landed
        if (fabs(velocity.vy) < 0.9f) {
            velocity.vy = 0.0f;
            [square restInPeace:[Vector2D createVectorWithComponentX:velocity.vx Y:8.0f]];
            isLanded = YES;
        }   
    } 

Translate the object

-(void) translateVelocity:(Vector2D*)velocity
{   
    // The center as well as all of the vertices need to be
    // accommodated.
    center.x += velocity.vx;
    center.y += velocity.vy;

    for(int i=0; i < count; i++)
    {
        points[i].x += velocity.vx;
        points[i].y += velocity.vy;

        ////NSLog(@"velocity %f %f",points[i].x , points[i].y);
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T19:55:21+00:00Added an answer on May 22, 2026 at 7:55 pm

    When using a bounce algorithm, it is usually recommended to implement a slight imperfection to make sure that this event does not happen. You could also largen the range of what is accepted as “Landed”, but remember to make sure that you then stick the object to the floor to make sure there are no visual artifacts.

    By the imperfection I mean :

    velocity.vy *= (-bounce + 0.01f);
    

    For example. This should make your object always come to a halt.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.