--定义菜单项
local scaleSmallMenuItem = nil --菜单项1
local scaleSmallMenuItem1 = nil --菜单项1
--回调方法
local function scaleSmallBtnCallFunc(tag, pMenuItem)
--按下菜单项1
if scaleSmallMenuItem == pMenuItem then
scaleSmallMenuItem:setVisible(false)
qipaoImg:setVisible(true)
scaleSmallMenuItem1:setVisible(true)
elseif scaleSmallMenuItem1 == pMenuItem then
scaleSmallMenuItem1:setVisible(false)
qipaoImg:setVisible(false)
scaleSmallMenuItem:setVisible(true)
end
end
--菜单项1
local scaleSmallBtn = cc.Sprite:createWithSpriteFrameName("button_xinjia.png")
scaleSmallMenuItem = cc.MenuItemImage:create();
scaleSmallMenuItem:setNormalSpriteFrame(scaleSmallBtn:getSpriteFrame())
scaleSmallMenuItem:setSelectedSpriteFrame(scaleSmallBtn:getSpriteFrame());
scaleSmallMenuItem:registerScriptTapHandler(scaleSmallBtnCallFunc)
--菜单项2
local scaleSmallBtn1 = cc.Sprite:createWithSpriteFrameName("button_xinjia1.png")
scaleSmallMenuItem1 = cc.MenuItemImage:create();
scaleSmallMenuItem1:setNormalSpriteFrame(scaleSmallBtn1:getSpriteFrame())
scaleSmallMenuItem1:setSelectedSpriteFrame(scaleSmallBtn1:getSpriteFrame());
scaleSmallMenuItem1:registerScriptTapHandler(scaleSmallBtnCallFunc)
--添加菜单项1
local scaleSmallMenu = cc.Menu:create(scaleSmallMenuItem)
scaleSmallMenu:setPosition((locX+180)*Scale_LayoutX, locY*Scale_LayoutY)
--添加菜单项2
scaleSmallMenu:addChild(scaleSmallMenuItem1)
layerGame:addChild(scaleSmallMenu)
scaleSmallMenuItem1:setVisible(false)