Welcome, Guest. Please login or register.

Login with username, password and session length

 
Advanced search

1411661 Posts in 69396 Topics- by 58452 Members - Latest Member: Monkey Nuts

May 16, 2024, 03:34:01 AM

Need hosting? Check out Digital Ocean
(more details in this thread)
TIGSource ForumsDeveloperTechnical (Moderator: ThemsAllTook)Box 2d Platform game problem
Pages: 1 [2]
Print
Author Topic: Box 2d Platform game problem  (Read 6044 times)
Sigma
Level 1
*


View Profile WWW
« Reply #20 on: November 16, 2009, 11:09:34 PM »

How to pause a game in box2d. I mean how to pause the physics simulation?
Logged

Bocom
Level 0
*


View Profile
« Reply #21 on: November 17, 2009, 02:00:11 AM »

How to pause a game in box2d. I mean how to pause the physics simulation?

Set your timestep to 0.
Logged
Sigma
Level 1
*


View Profile WWW
« Reply #22 on: November 18, 2009, 09:51:49 PM »

thanx for the help...
Logged

Sigma
Level 1
*


View Profile WWW
« Reply #23 on: November 24, 2009, 09:32:26 PM »

when my character stands at the very tip of a platform it is not jumping?

Code Below:

   
_body.m_userData.width = 20;
_body.m_userData.height = 50;
      
private function jump():void
{
     if (_body.GetLinearVelocity().y > -1)
     {
            
   var Hit = GetBodyAtPoint(_body.m_userData.x, _body.m_userData.y+ (_body.m_userData.height/2+2), true);//Under

   var Hit1 = GetBodyAtPoint(_body.m_userData.x-(_body.m_userData.width/2)+2, _body.m_userData.y+(_body.m_userData.height/2+2), true);//Down-Left

        var Hit2 = GetBodyAtPoint(_body.m_userData.x+(_body.m_userData.width/2)-2, _body.m_userData.y+(_body.m_userData.height/2+2), true);//Down-Right
         
   if (Hit != null && Hit.m_userData != _body.m_userData )
   {
      _body.ApplyImpulse(new b2Vec2(0.0, -GameConstants.jumpVelocity), _body.GetWorldCenter());//Applys and impuls to the player. (Makes it jump)
   }
   else if (Hit1 != null && Hit1.m_userData != _body.m_userData &&  Hit2 != null && Hit2.m_userData != _body.m_userData)
   {
      _body.ApplyImpulse(new b2Vec2(0.0, -GameConstants.jumpVelocity), _body.GetWorldCenter());//Applys and impuls to the player. (Makes it jump)
   }
            }
         _body.m_sweep.a = 0;
        }

         
      public function GetBodyAtPoint(px:Number, py:Number, includeStatic:Boolean = false) : b2Body
   {
      // Make a small box.
      var px2 = px/Environment.RATIO;
      var py2 = py/Environment.RATIO;
      var PointVec:b2Vec2 = new b2Vec2();
      PointVec.Set(px2, py2);
      var aabb:b2AABB = new b2AABB();
      aabb.lowerBound.Set(px2 - 0.001, py2 - 0.001);
      aabb.upperBound.Set(px2 + 0.001, py2 + 0.001);
         
      // Query the world for overlapping shapes.
      var k_maxCount:int = 10;
      var shapes:Array = new Array();
      var count:int = Environment._world.Query(aabb, shapes, k_maxCount);
      var body:b2Body = null;
         
      // The loop that seeks for the body:
      for (var i:int = 0; i <count; ++i) {
         if (shapes.m_body.IsStatic() == false || includeStatic) {
            var tShape:b2Shape = shapes as b2Shape;
            var inside:Boolean = tShape.TestPoint(tShape.m_body.GetXForm(), PointVec);
         if (inside) {
               body = tShape.m_body;
               break;
            }
         }
       }
      return body;
   }
      
Logged

Sigma
Level 1
*


View Profile WWW
« Reply #24 on: December 22, 2009, 12:05:48 AM »

how to save the game progress? so that when the player visits again he/she can continue...
I need to store some values.It is a web application so guys tell me the best approach to save and load data...

Thanks in Adance.......
Logged

bateleur
Level 10
*****



View Profile
« Reply #25 on: December 22, 2009, 04:02:29 AM »

Saving data for web games is usually best done with SharedObject.
Logged

Sigma
Level 1
*


View Profile WWW
« Reply #26 on: December 24, 2009, 04:06:11 AM »

thnx a lot for the reply...
Logged

Sigma
Level 1
*


View Profile WWW
« Reply #27 on: January 15, 2010, 03:11:18 AM »

Hi guys,
  To pause the game i assigned time step  equals 0; but the thing is, the dynamic objects in an environment which is not at sleep while pausing; starts moving randomly all over the screen. can anyone tell me the reason behind?
Logged

Sigma
Level 1
*


View Profile WWW
« Reply #28 on: February 12, 2010, 02:01:02 AM »

Hi guys,
    when the application is idle for a long time the lags badly. can anyone tell me why?
Logged

Pages: 1 [2]
Print
Jump to:  

Theme orange-lt created by panic