In my app (JR Chemistry Set:
http://itunes.com/apps/jrchemistryset ) I have a Box2d game component where users can touch/move a bouncing ball (chemical element) and place them in a preset mold where a weld joint holds them in place.
I've had some user feedback complaining that the bouncing balls are "too hard to grab". For the most part I think they are simply un-used to touch/grab (i.e. inexperienced users) but still I guess I should try to accommodate them if it doesn't inhibit game play.
I am wondering how to increase the touch area of the bouncing balls so they are easier to "grab". Looking through my code it seems I might be able to achieve this in TouchBegan (included below).
Your thoughts? Do I just increase the size of "d" below?
- (BOOL)ccTouchBegan:(UITouch *)touch withEvent:(UIEvent *)event {
CGPoint location = [self convertTouchToNodeSpace:touch];
int in_game = [[NSUserDefaults standardUserDefaults] integerForKey:@"CCLayer"];
if (in_game == 1) {
m_mouseWorld.Set(ptm(location.x), ptm(location.y));
if (m_mouseJoint != NULL)
{
CCLOG(@"hello2");
}
b2AABB aabb;
b2Vec2 d = b2Vec2(0.001f, 0.001f);
aabb.lowerBound = m_mouseWorld - d;
aabb.upperBound = m_mouseWorld + d;
// Query the world for overlapping shapes.
QueryCallback callback(m_mouseWorld);
world->QueryAABB(&callback, aabb);
if (callback.m_fixture)
{
b2BodyDef bodyDef;
b2Body* groundBody = world->CreateBody(&bodyDef);
b2Body* bodyz = callback.m_fixture->GetBody();
bodyz->SetAwake(true);
b2MouseJointDef md;
md.bodyA = groundBody;
md.bodyB = bodyz;
md.target = m_mouseWorld;
md.maxForce = 1000.0f * bodyz->GetMass();
m_mouseJoint = (b2MouseJoint*)world->CreateJoint(&md);
}
return TRUE;
}
//to prevent touches being passed to this handler when not in the game
return FALSE;
}