public MenuLayer(boolean playMusic) { if (playMusic) { if (G.bgSound.isPlaying()) G.bgSound.pause(); G.bgSound = G.soundMenu; if (G.music) G.bgSound.start(); } setScale(G.scale); setAnchorPoint(0, 0); // background CCSprite bg = new CCSprite("background/game_bg0.png"); bg.setPosition(G.displayCenter()); addChild(bg); CCSprite bird = new CCSprite("menu/bird.png"); bird.setAnchorPoint(0, 0); bird.setPosition(0, 0); addChild(bird); CCSprite leaves = new CCSprite("menu/leaves.png"); leaves.setAnchorPoint(0, 1); leaves.setPosition(0, G.height); addChild(leaves); CCSprite title = new CCSprite("menu/title.png"); title.setPosition(G.width * 0.47f, G.height * 0.83f); addChild(title); // remove Ads /*CCMenuItemImage removeAds = CCMenuItemImage.item("menu/no_ads.png", "menu/no_ads.png", this, "removeAds_Menu"); removeAds.setAnchorPoint(1, 0); removeAds.setPosition(G.width, G.height*0.4f);*/ // buttons CCMenuItemImage play = CCMenuItemImage.item("menu/play1.png", "menu/play2.png", this, "onPlay"); play.setAnchorPoint(1, 0); play.setPosition(G.width, 0); CCMenuItemToggle sound = CCMenuItemToggle.item( this, "onSound", CCMenuItemImage.item("menu/sound_off.png", "menu/sound_off.png"), CCMenuItemImage.item("menu/sound_on.png", "menu/sound_on.png")); sound.setSelectedIndex(G.sound ? 1 : 0); sound.setPosition(G.width * 0.4f, 70); CCMenuItemToggle music = CCMenuItemToggle.item( this, "onMusic", CCMenuItemImage.item("menu/music_off.png", "menu/music_off.png"), CCMenuItemImage.item("menu/music_on.png", "menu/music_on.png")); music.setSelectedIndex(G.music ? 1 : 0); music.setPosition(G.width * 0.5f, 70); CCMenuItemImage game_center = CCMenuItemImage.item( "menu/leaderboard.png", "menu/leaderboard_clicked.png", this, "onLeaderBoard"); game_center.setAnchorPoint(0.5f, 0); game_center.setPosition(G.width * 0.5f, 140); // for more CCMenuItemImage moreItem = CCMenuItemImage.item("menu/more.png", "menu/more1.png", this, "openMoreGames"); moreItem.setAnchorPoint(0.5f, 0); moreItem.setPosition(G.width * 0.4f, 140); CCMenuItemImage moreItem2 = CCMenuItemImage.item("menu/more2.png", "menu/more2.png", this, "superchaves"); moreItem2.setAnchorPoint(0.5f, 0); moreItem2.setPosition(G.width * 0.6f, 140); CCMenu menu = CCMenu.menu(/*removeAds ,*/ play, sound, music, game_center, moreItem, moreItem2); menu.setPosition(0, 0); addChild(menu); setIsKeyEnabled(true); }