Connect sprites into 1 Button

IlledanIlledan NOMember ✭✭

Hi!

What I need: A button with some images and some labels. Se example (not done styling..)

Data on the button is dynamic (more damage on next uppgrade.. etc.)

I could put in a bunch of stuff and place it on the CCMenuItemImage by calculating Position'n stuff, but that's heavy work for many buttons.

I`m hoping some kind of container exists, which I could use for arranging items inside the container.. Any suggestions?

-Illedan

Tagged:

Best Answers

Answers

  • IlledanIlledan NOMember ✭✭

    Works!
    I've been using CCMenuItems wrong, since I never found a guide about it. Thx!

  • IlledanIlledan NOMember ✭✭

    If anyone else wonders.. This works:
    `
    class SquareButton : CCMenuItemImage
    {
    public ShopSquareButton (CCSprite image, Action target, string topText, string middleText, string cost)
    {
    NormalImage = new CCSprite ("...");
    SelectedImage = new CCSprite ("...");
    AnchorPoint = CocosSharp.CCPoint.AnchorMiddle;
    image.PositionX = this.ContentSize.Width/2.0f;
    image.PositionY = this.ContentSize.Height/2.0f;
    image.AnchorPoint = CocosSharp.CCPoint.AnchorMiddle;
    this.AddChild (image, 1);
    Target = target;

            //Label's'n stuff.
        }
    }
    

    ...
    In CCLayerColor:
    var menu = new CCMenu (new CCMenuItem[]{new ShopSquareButton(sprite, DamageBought, "DAMAGE", "+20", "200")});
    AddChild(menu)..
    `

Sign In or Register to comment.