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 3989922
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T06:25:57+00:00 2026-05-20T06:25:57+00:00

I have a Box2D world which works great. I’m using it in a simple

  • 0

I have a Box2D world which works great. I’m using it in a simple iOS game where the user tilts the device to push bodies around the screen racking up points when a certain body collides with another.

It was working fine when it was buried a couple layers deep in my app in a test controller. I invoked it from a button on my menu screen and a button on the game screen would return to the menu just fine via popToViewController. But once I saw how great it worked I realized that I wanted the game to be the first screen a user sees (after the default loading image). So now the app loads the world and the game is on right off the bat without any problems.

Until the user taps the menu button to get to the menu screen – another view controller. The menu controller loads fine and everything works there as expected. BUT when one taps the back button to return to the game/world the images/bodies are distorted. The distortion varies depending on how they happened to be rotated when the menu controller got pushed onto the navigation stack. Sometimes they are enlarged and sometimes smooshed.

I did try pausing the world (by not calling Step) when loading the menu controller, but that did not help with the image distortion problem.

Here is the code where the menu controller gets loaded:

  //unhide the navbar for the next screen
   [self.navigationController setNavigationBarHidden:NO];

   MenuViewController *mvc = [[MenuViewController alloc]init];

   [self.navigationController pushViewController:mvc animated:YES];

   [mvc release];

And here is where the game’s view controller gets loaded by the app delegate in application didFinishLaunchingWithOptions:

   B2DViewController *b2dvc = [[B2DViewController alloc]init];

   UINavigationController *navcon = [[UINavigationController alloc] init];

   [navcon setNavigationBarHidden:YES];

   [navcon pushViewController:b2dvc animated:NO];
   [window addSubview:navcon.view];

   [b2dvc release];

    [window makeKeyAndVisible];

The images come in via a xib. One is button and one is an imageView. Both are added to dynamic bodies which are configured thusly:

    b2PolygonShape dynamicBox;
    dynamicBox.SetAsBox(boxDimensions.x, boxDimensions.y);

 ...

    b2FixtureDef fixtureDef; 
    fixtureDef.shape = &dynamicBox;
    fixtureDef.density = 3.0f;
    fixtureDef.friction = 0.3f;
    fixtureDef.restitution = 0.5f;

  ...

I tried hiding all the subviews but, as you might suspect, that only hid them from view, not from the forces of distortion. I also turned off all the stretching and resizing stuff in IB, to no avail (I was just guessing).

I’d be grateful for any assistance or ideas that anyone might have.

  • 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-20T06:25:57+00:00Added an answer on May 20, 2026 at 6:25 am

    Instead of pushing the menu controller onto the navigation controller and then adding the navigation controller to the view I instead used presentModalViewController: animated. This didn’t fix the problem, but once I commented out [self.navigationController setNavigationBarHidden:NO]; the problem was resolved.

    //unhide the navbar for the next screen
    //[self.navigationController setNavigationBarHidden:NO];
    
    MenuViewController *mvc = [[MenuViewController alloc]init];
    
    [self presentModalViewController:(UIViewController *)mvc  animated:YES];
    [mvc release];
    

    It seems that the NavigationBar was smashing the images? I’d like to look into this further as the navigation bar can be a handy thing, but I don’t have time now, which probably means I’ll never get around to it.

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

Sidebar

Related Questions

I'm using AndEngine/Box2d to develop a game. I have a ball that bounces around
I am trying to write an iPhone game using cocos2d and Box2D, which means
I'm developing a physics game using AndEngine with box2d physics engine. I have a
I am using the cocos2d-iphone + Box2d engine, I have a simple call in
I'm using Box2d for a Bike Physics Game, Box2d lets you have fixtures that
I'm developing 2D Side scroll Android Game, using AndEngine and its BOX2D extension. I
I have a body (player) in my box2d world. Whenever I try to set
Some Background: I make Box2D games using WCK, which is an alchemy port of
I have special problem which I am trying to solve using CSS. My HTML
When creating a world in Box2D you have the option to enable bodies to

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.