CCLabel strange behaviour

MarkoBrkovicMarkoBrkovic HRMember ✭✭

I'm developing iOS application and I'm having trouble with CCLabel positioning. Whatever I try I can't change the position of CCLabel object. I even tried to put it in an empty CCNode and change its position. In that case position changes but with weird results, label is positioned in completely wrong place. Am I doing something wrong? My code follows (AddedToScene method in a layer):

protected override void AddedToScene ()
{
base.AddedToScene ();

CCLabel label = new CCLabel ("Some random text", "Courier", 18, CCTextAlignment.Left, CCVerticalTextAlignment.Center);
label.Color = CCColor3B.Black;
label.Position = new CCPoint (100, 100);

AddChild (label);

}

Posts

  • RamiTabbaraRamiTabbara AUMember, Xamarin Team Xamurai

    Hi Marko,

    Are you adding the label to an empty CCNode? If so, make sure that the ContentSize of the CCNode is non-zero.

    Please let me know if that fixes the problem.

  • kjpou1kjpou1 LUMember, Xamarin Team Xamurai

    Hey Marko

    Also, there were some fixes placed in the code base at the end of last week to fix layout problems with CCLabelBMFont and consequently CCLabel.

  • MarkoBrkovicMarkoBrkovic HRMember ✭✭
    edited August 2014

    CCNode labelHolder = new CCNode ();
    labelHolder.ContentSize = new CCSize (100, 100);
    labelHolder.Position = new CCPoint (300, 300);

    CCLabel label = new CCLabel ("Some random text", "Courier", 18, CCTextAlignment.Left, CCVerticalTextAlignment.Center);
    label.Color = CCColor3B.Black;

    labelHolder.AddChild (label);
    AddChild (labelHolder);

    The code above produces also strange result as stated in my first post. If I'm right , in this case the label should appear at 300.300 position, but it appears at approximately 600.400..

    @kjpou1 I added CocosSharp.iOS reference with Nuget package manager. Should I maybe fetch latest version from GitHub?

  • kjpou1kjpou1 LUMember, Xamarin Team Xamurai

    Marko

    I think it best to fetch latest from development right now for that problem. Really hate to say that to be honest.

    I would post a NuGet for you here but do not want to get into the habit of doing that. We will be updating the nugets soon as a bug fix release but waiting on one more change.

  • kjpou1kjpou1 LUMember, Xamarin Team Xamurai

    Marko

    I think it best to fetch latest from development right now for that problem. Really hate to say that to be honest.

    I would post a NuGet for you here but do not want to get into the habit of doing that. We will be updating the nugets soon as a bug fix release but waiting on one more change.

  • MarkoBrkovicMarkoBrkovic HRMember ✭✭

    Ok, thank you for your reply. I think I'll stick to NuGet for now. Thing is that in this stage of development process these labels are not crucial, so I'll do other work until NuGet is ready.

Sign In or Register to comment.