cocos2d-x-lua:API-Toggle菜单

Toggle 菜单:由两个“图片菜单项”组成

创建函数:cc.MenuItemToggle:create

    --sound Toggle
    local soundOnMenuItem = cc.MenuItemImage:create("on.png","on.png")
    local soundOffMenuItem = cc.MenuItemImage:create("off.png","off.png")
    
    local soundToggleMenuItem = cc.MenuItemToggle:create(soundOnMenuItem,soundOffMenuItem)
    soundToggleMenuItem:setPosition(250,100 )

    --music Toggle   
    local musicOnMenuItem = cc.MenuItemImage:create("on.png","on.png")
    local musicOffMenuItem = cc.MenuItemImage:create("off.png","off.png")

    local musicToggleMenuItem = cc.MenuItemToggle:create(musicOnMenuItem,musicOffMenuItem)
    musicToggleMenuItem:setPosition(250,-30 )
    
    
    local mn = cc.Menu:create(soundToggleMenuItem,musicToggleMenuItem)
--    mn:alignItemsVertically()
    layer:addChild(mn)








你可能感兴趣的:(cocos2d-x-lua)