Box2D Forums

It is currently Thu May 23, 2013 5:19 pm

All times are UTC - 8 hours [ DST ]




Post new topic Reply to topic  [ 5 posts ] 
Author Message
PostPosted: Wed Feb 15, 2012 4:19 pm 
Offline

Joined: Wed Feb 15, 2012 4:12 pm
Posts: 5
I have a very nasty issue and not sure at all where it comes from ..
I'm using AIR 3.2 , targeting iOS , within Flash Builder 4.6. I'm not using flash authoring..

This is the RTE I'm getting when creating a b2Fixture from a shape or from the body. Here the stack:
TypeError: Error #1006: value is not a function.
at cmodule.Box2D::FSM__Z20b2Body_CreateFixturePvP8_AS3_Val/work()
at Function/()
at Function/()
at Box2DAS.Dynamics::b2Fixture()[/Developer/Repositories/app/app-client/src/main/air/Box2DAS/Dynamics/b2Fixture.as:25]
at Box2DAS.Collision.Shapes::b2Shape/create()[/Developer/Repositories/app/app-client/src/main/air/Box2DAS/Collision/Shapes/b2Shape.as:26]


This is what i'm doing:

in Main constructor I call:

Code:
b2Base.initialize()


This is the part that cause the RTE:

Code:
body = world.CreateBody(new b2BodyDef());
var circle:b2CircleShape = new b2CircleShape(radius*scale);
var fixture:b2Fixture= shape.create(body);


Please help ;)


Top
 Profile  
 
PostPosted: Thu Feb 16, 2012 4:10 am 
Offline

Joined: Wed Feb 15, 2012 4:12 pm
Posts: 5
Ok so here a simple actionscript test case that demonstrate the RTE:

Code:
package
{
   import Box2DAS.Collision.Shapes.b2CircleShape;
   import Box2DAS.Common.V2;
   import Box2DAS.Common.b2Base;
   import Box2DAS.Common.b2Def;
   import Box2DAS.Dynamics.b2Body;
   import Box2DAS.Dynamics.b2Fixture;
   import Box2DAS.Dynamics.b2World;
   
   import flash.display.Sprite;
   import flash.events.Event;
   
   public class b2dAlchemy extends Sprite
   {
      private var world:b2World;
      private var body:b2Body;
      
      public function b2dAlchemy()
      {
         if(stage)
            initB2d();
         else
            addEventListener(Event.ADDED_TO_STAGE, addedToStageHandler);
         
      }
      
      private function initB2d():void
      {
         b2Base.initialize();
         
         world = new b2World(new V2(0,0),true);
         body = world.CreateBody(b2Def.body);
         var circle:b2CircleShape = new b2CircleShape(160);
         var fixture:b2Fixture= circle.create(body);
      }
      
      protected function addedToStageHandler(event:Event):void
      {
         removeEventListener(Event.ADDED_TO_STAGE,addedToStageHandler);
         
         initB2d();
      }
      
      
   }
}


Top
 Profile  
 
PostPosted: Thu Feb 16, 2012 5:32 am 
Offline

Joined: Wed Feb 15, 2012 4:12 pm
Posts: 5
I also rebuilt the SWC with alchemy .. same thing ...
I'm really wondering whats wrong .. maybe i do something wrong or not. Is there someone who can help me on this please ?

Thanks in advance


Top
 Profile  
 
PostPosted: Sat Feb 18, 2012 3:37 pm 
Offline

Joined: Fri Dec 14, 2007 8:07 pm
Posts: 913
Ok finally figured this one out. The first parameter to the circle constructor function is a pointer to a C++ circle object, not radius which I assume you assumed it was. This works:

Code:
world = new b2World(new V2(0,0),true);
body = world.CreateBody(b2Def.body);
var circle:b2CircleShape = new b2CircleShape();
circle.m_radius = 160;
var fixture:b2Fixture= circle.create(body);


So it was trying to dereference 160 in memory and didn't find a circle shape there.


Top
 Profile  
 
PostPosted: Sun Feb 19, 2012 1:14 pm 
Offline

Joined: Wed Feb 15, 2012 4:12 pm
Posts: 5
Thanks a lot for your help. At the end it seems it is my mistake .. sorry for that :)


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC - 8 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group