ios - how to rotate sprite with 180 degree cocos2d-iphone? -


-(void) cctouchmoved:(uitouch *)touch withevent:(uievent *)event     {         cgpoint location = [touch locationinview:[touch view]];         location = [[ccdirector shareddirector] converttogl:location];          shootvector = ccpsub(location, cannon.position);         cgfloat shootangle = ccptoangle(shootvector);         cocosangle = cc_radians_to_degrees(-1 * shootangle);          cgfloat rotatediff = cocosangle;             if (rotatediff > 180)             rotatediff -= 360;         if (rotatediff < -180)             rotatediff += 360;              cgfloat rotatespeed = 360;          rotateduration = fabs(rotatediff / rotatespeed);          [cannon runaction:[ccsequence actions:                            [ccrotateto actionwithduration:rotateduration angle:cocosangle],                            [cccallfunc actionwithtarget:nil selector:nil],                            nil]];          top.rotation = cannon.rotation;     } 

above code cause rotation on touch moved 360 degree,instead want rotate cannon in 180 or less degree..

any appreciated.

using ccrotateby command instead of ccrotateto cause rotation of amount instead of going position. call in same way ccrotateto below:

[ccrotateby actionwithduration:rotateduration angle:180] 

Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -