objective c - Variable return runtime error -
i making iphone app cocos2d , everytime try return variable function run time error on code below...
gb2shapecache *cache = [gb2shapecache sharedshapecache]; //exc_bad_access run time error here *eggfixture = [cache addfixturestobody:body forshapename:@"egg3"];
i don't know doing wrong... here code addfixturestobody...
-(b2fixture) addfixturestobody:(b2body*)body forshapename:(nsstring*)shape { bodydef *so = [shapeobjects objectforkey:shape]; assert(so); b2fixture *fixi; fixturedef *fix = so->fixtures; while(fix) { fixi = body->createfixture(&fix->fixture); fix = fix->next; } return *fixi; }
and here define variable eggfixture
b2fixture *eggfixture;
and here try use b2fixture eggfixture later
for(pos = _contactlistener->_contacts.begin(); pos != _contactlistener->_contacts.end(); ++pos) { mycontact contact = *pos; if ((contact.fixturea == locations.platformfixture && contact.fixtureb == eggfixture) || (contact.fixturea == eggfixture && contact.fixtureb == locations.platformfixture)) { nslog(@"ball hit bottom!"); } }
any help? thankyou :)
looks body
nil. crash here when body nil:
fixi = body->createfixture(&fix->fixture);
Comments
Post a Comment