How to do menus

Hi All, I've been struggling all day to get some simple menus up and running. I can't seem to get anything to work with CCMenu and CCMenuItems*. My sample code is below which is to be found in a CCLayerColor Class.

    CCMenu menu;
    CCMenuItem menuitem1;

    menuitem1 = new CCMenuItemLabel(new CCLabel("Back", "arial", 40f),  delegate(object obj)
             {
                     Console.WriteLine("button clicked!");
              });
     menuitem1.Position = new CCPoint(500f, 500f);
     List<CCMenuItem> items = new List<CCMenuItem>();
     items.Add(menuitem1);
    menu = new CCMenu(items.ToArray());
    AddChild(menu);

Nothing shows up but other CCSprites show up fine. Does anybody know how to work CCMenu or point me to a tutorial in C# please?

Many thanks,
John

Posts

  • RamiTabbaraRamiTabbara AUMember, Xamarin Team Xamurai

    Hi John,

    We have raised this issue relating to your problem. It should be specific to CCMenuItemLabel, however as a test, check out CCMenuItemImage -- that is, try creating menu items containing sprites instead of labels to see if you encounter the same problem.

    Also as an aside, when creating your menu you can instead do the following

    
    new CCMenu(item1, item2, etc.)
    
    

    so you don't need to create an array and then pass that into the constructor.

  • JohnTamJohnTam GBMember, University ✭✭

    Hi Rami,

    Thanks for your reply and your tip. I can confirm that CCMenuItemImage works ok.

    Cheers,
    John

Sign In or Register to comment.