Hello.
At the very high risk of looking like a complete idiot, I need to ask the following. :)
I'm using SpaceManager, after getting some help from QCMat_ on the IRC yesterday (thanks again) and reading as much as I can find and grasp I've managed to get physics working in my test level, and I'm very happy.
Today my goal is to apple impulses to my single object. Looking at this:
http://code.google.com/p/chipmunk-spacemanager/wiki/Introduction
makes it seem very simple, and in my test case it's simpler still, simply press the screen and apply a quick impulse to keep an object in the air. No touches and it hits the floor, simple yes? My problem is that I have a standard init method with the standard set up for a cocos layer, I add objects to this layer, they display, I then a method which configures spacemanager, all good. When I come to using this method however:
- (BOOL)ccTouchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
CGPoint pt = [self convertTouchToNodeSpace:[touches anyObject]];
CGPoint forceVect = ccpSub(pt, ballSprite.position);
[ballSprite applyImpulse:ccpMult(forceVect, 100)];
return kEventHandled;
}
changing the specifics to match my level objects, I get 'xObject is undeclared'. In other words, I've created the object in the spacemanager setup method, and so it can't be seen by the touches method.
Should I create the objects in the header file, synthesize them, then point everything to those variables? That's what I'd do in Flash, but I can't figure that one out in Cocoa. :)
I'll try to post code later, main system is having a new PSU fitted.
Thanks.
p.s. Apologies for not putting this in the physics section.