public CocosDenshionTest() { m_pItmeMenu = null; m_tBeginPos = new CCPoint(0,0); m_nSoundId = 0; string[] testItems = { "play background music", "stop background music", "pause background music", "resume background music", "rewind background music", "is background music playing", "play effect", "play effect repeatly", "stop effect", "unload effect", "add background music volume", "sub background music volume", "add effects volume", "sub effects volume" }; // add menu items for tests m_pItmeMenu = CCMenu.menuWithItems(null); CCSize s = CCDirector.sharedDirector().getWinSize(); m_nTestCount = testItems.Count<string>(); for (int i = 0; i < m_nTestCount; ++i) { CCLabelTTF label = CCLabelTTF.labelWithString(testItems[i], "Arial", 24); CCMenuItemLabel pMenuItem = CCMenuItemLabel.itemWithLabel(label, this, new SEL_MenuHandler(menuCallback)); m_pItmeMenu.addChild(pMenuItem, i + 10000); pMenuItem.position = new CCPoint( s.width / 2, (s.height - (i + 1) * LINE_SPACE) ); } m_pItmeMenu.contentSize = new CCSize(s.width, (m_nTestCount + 1) * LINE_SPACE); m_pItmeMenu.position = new CCPoint(0,0); addChild(m_pItmeMenu); this.isTouchEnabled = true; // preload background music and effect SimpleAudioEngine.sharedEngine().preloadBackgroundMusic(CCFileUtils.fullPathFromRelativePath(MUSIC_FILE)); SimpleAudioEngine.sharedEngine().preloadEffect(CCFileUtils.fullPathFromRelativePath(EFFECT_FILE)); // set default volume SimpleAudioEngine.sharedEngine().setEffectsVolume(0.5f); SimpleAudioEngine.sharedEngine().setBackgroundMusicVolume(0.5f); }
public TestController() { CCDirector.sharedDirector().deviceOrientation = ccDeviceOrientation.CCDeviceOrientationLandscapeLeft; m_tBeginPos = new CCPoint(0.0f, 0.0f); CCSize s = CCDirector.sharedDirector().getWinSize(); // add close menu CCMenuItemImage pCloseItem = CCMenuItemImage.itemFromNormalImage(TestResource.s_pPathClose, TestResource.s_pPathClose, this, new SEL_MenuHandler(closeCallback)); pCloseItem.anchorPoint = new CCPoint(0, 0); CCMenu pMenu = CCMenu.menuWithItems(pCloseItem); pMenu.position = new CCPoint(s.width - 40, 10); // add menu items for tests m_pItemMenu = CCMenu.menuWithItems(null); for (int i = 0; i < (int)(TestCases.TESTS_COUNT); ++i) { // todo, CCMenuItemLabel hasn't been implemented, use CCMenuItemImage instead CCLabelTTF label = CCLabelTTF.labelWithString(Tests.g_aTestNames[i], "Arial", 24); CCMenuItemLabel pMenuItem = CCMenuItemLabel.itemWithLabel(label, this, new SEL_MenuHandler(menuCallback)); //CCMenuItemImage pMenuItem = CCMenuItemImage.itemFromNormalImage(TestResource.s_pPathGrossini, TestResource.s_pPathGrossini, this, new SEL_MenuHandler(menuCallback)); m_pItemMenu.addChild(pMenuItem, i + 10000); pMenuItem.position = new CCPoint(s.width / 2, (s.height - (i + 1) * LINE_SPACE)); } m_pItemMenu.contentSize = new CCSize(s.width, ((int)(TestCases.TESTS_COUNT) + 1) * LINE_SPACE); m_pItemMenu.position = (s_tCurPos); addChild(m_pItemMenu); isTouchEnabled = true; addChild(pMenu, 1); }
public override void onEnter() { base.onEnter(); CCSize s = CCDirector.sharedDirector().getWinSize(); m_pItmeMenu = CCMenu.menuWithItems(null); CCMenuItemFont.FontName = "Arial"; CCMenuItemFont.FontSize = 24; for (int i = 0; i < BugsTestScene.MAX_COUNT; ++i) { CCMenuItemFont pItem = CCMenuItemFont.itemFromString(BugsTestScene.testsName[i], this, menuCallback); pItem.position = new CCPoint(s.width / 2, s.height - (i + 1) * BugsTestScene.LINE_SPACE); m_pItmeMenu.addChild(pItem, BugsTestScene.kItemTagBasic + i); } m_pItmeMenu.position = BugsTestScene.s_tCurPos; addChild(m_pItmeMenu); isTouchEnabled = true; }