objective c - How to apply impulse on chipmunk body on a specific direction? -


i using:

 cpvect vector1=cpv(angle, 400);   [body applyforce:vector1 offset:vector1]; 

but not working needed put correct angle using touch screen below line of code used getting angle

-(void)cctouchesmoved:(nsset *)touches withevent:(uievent *)event {     for( uitouch *touch in touches )     {         cgpoint location = [touch locationinview: [touch view]];         location = [[ccdirector shareddirector] converttogl: location];         float angleradians = atanf((float)location.y/ (float)location.x-1);         float angledegrees = cc_radians_to_degrees(angleradians);         float cocosangle = -1 * angledegrees;        angle = angledegrees + 30;     } } 

thanks precious time give on that. found way achieve impulse on chipmunk body on specific direction. using below code.

 **angle = angle-90;                  //angle cctouchesmoved function  float magnitude=shootpower;        // magnitude range between 200 1000  cpvect impulse = cpv((cos(angle) * magnitude) , -(sin(angle) * magnitude));   [body applyimpulse:impulse offset:cpvzero];** 

// applyimpulse gives right way putting impulse needed using above sin , cos theta values.


Comments

Popular posts from this blog

c++ - Creating new partition disk winapi -

Android Prevent Bluetooth Pairing Dialog -

VBA function to include CDATA -