CCCamera Rotation

I have started building a top-down shooter using the CCCamera object. I love the ease of use for movement and zoom functionality, but I am having trouble figuring out how to rotate the Camera object. I have figured out how to use the TargetInWorldspace and CenterInWorldspace properties to move the camera around. My goal is to have the camera pivot at the center of the screen. I understand that I can rotate the CCLayer to simulate the rotation of the camera, but I would prefer not having to manage any offset values for the sprites and such. Does anyone have any insight into the CCCamera, maybe using the UpDirection or something? Thank you for your time :).


  • JamesSchuetzJamesSchuetz USMember

    I took a look at the CocosSharp source for the CCCamera and noticed that it is using microsoft xna matrix functions, this Microsoft article may provide a solution. I am at work right now and I will see if this is the solution when I get home.

  • JamesSchuetzJamesSchuetz USMember
    edited January 2015

    I was able to solve my issue, below is the code that I came up with after a few beers and curse words. Basically the UpDirection property does determine the rotation of the view.

    float angle = MathHelper.ToRadians (currentAngle += 15); Vector3 transformed = Vector3.Transform(Vector3.Up,Matrix.CreateRotationZ(angle)); mainLayer.Camera.UpDirection = new CCPoint3 (transformed.X,transformed.Y,transformed.Z);

Sign In or Register to comment.