Forum Libraries, Components, and Plugins

rotate box using local space?

Hi,

CCSharp is new to me and I am still struggling.

I want a box with text in it. The box should eventually scale,rotate and position through touch gestures.
So far in my IntroLayer, I got the text in the box and positioned it roughly at the center of the screen. But when I rotate 45 degrees, the rotation is not applied to the local space of the box but it looks like it rotates on the (0,0) of the worldspace/screen. See attached screencap. What am I doing wrong?

        // Create label 
        CCLabel label;
        label = new CCLabel("Touch me", "fonts/MarkerFelt", 22, CCLabelFormat.SpriteFont);
        label.HorizontalAlignment = CCTextAlignment.Center;
        label.VerticalAlignment = CCVerticalTextAlignment.Center;
        label.Color = CCColor3B.Green;

        // Create parent 100x100 box in center of screen
        box = new CCDrawNode();
        box.DrawRect(new CCPoint(350,500),100, CCColor4B.White);


        // Position the label to box center
        var x = box.BoundingRect.MidX;
        var y = box.BoundingRect.MidY;
        label.Position = new CCPoint(x, y);

        // Parent the box to the label
        box.AddChild(label, 100);

        AddChild(box);

        // Rotate the box
        box.Rotation = 45;
Tagged:
Sign In or Register to comment.