在 Cocos2d Windows phoneI 中创建 Menutem



我想在单个菜单中添加一个精灵和标签项,两者都是可点击的,但在 C# 中,您不能从多个类扩展。

我从menuItemLabel类扩展并使用menuItemSprite组成类。

但是当我单击标签时,它工作正常,但菜单项精灵没有响应单击事件。

如果有人知道这个问题的解决方案,请回复。

public class menuitem4 : CCMenuItemLabel
{
    public static menuitem4 itemwith(CCNode normal, CCNode selected, CCNode label, SelectorProtocol target, SEL_MenuHandler selector)
    {
        menuitem4 pRet = new menuitem4();
        pRet.a = CCMenuItemLabel.itemWithLabel(label,target, selector);
        Specie1Store sp = (Specie1Store)target;
        pRet.a.position = new CCPoint(500,100);
        sp.addChild(pRet.a);
        pRet.initWithLabel(label, target, selector);
        return pRet;
    }
}

您可以创建一个扩展 CCNode 的类,并将 CCMenuItemImage 和 CCMenuItemLabel 添加为子项。

最新更新