public override void OnEnter() { base.OnEnter(); m_grossini = new CCSprite(TestResource.s_pPathGrossini); m_tamara = new CCSprite(TestResource.s_pPathSister1); m_kathia = new CCSprite(TestResource.s_pPathSister2); AddChild(m_grossini, 3); AddChild(m_kathia, 2); AddChild(m_tamara, 1); var s = CCDirector.SharedDirector.WinSize; m_grossini.Position = new CCPoint(60, 50); m_kathia.Position = new CCPoint(60, 150); m_tamara.Position = new CCPoint(60, 250); var label = new CCLabelTTF(title(), "arial", 32); AddChild(label); label.Position = new CCPoint(s.Width / 2, s.Height - 50); var item1 = new CCMenuItemImage(TestResource.s_pPathB1, TestResource.s_pPathB2, backCallback); var item2 = new CCMenuItemImage(TestResource.s_pPathR1, TestResource.s_pPathR2, restartCallback); var item3 = new CCMenuItemImage(TestResource.s_pPathF1, TestResource.s_pPathF2, nextCallback); var menu = new CCMenu(item1, item2, item3); menu.Position = CCPoint.Zero; item1.Position = new CCPoint(s.Width / 2 - 100, 30); item2.Position = new CCPoint(s.Width / 2, 30); item3.Position = new CCPoint(s.Width / 2 + 100, 30); AddChild(menu, 1); }
public override void OnEnter() { base.OnEnter(); CCSize s = CCDirector.SharedDirector.WinSize; CCLabelTTF label = new CCLabelTTF(title(), "arial", 24); AddChild(label); label.Position = new CCPoint(s.Width / 2, s.Height - 50); string subTitle = m_pNotificationLayer.subtitle(); if (subTitle != null) { CCLabelTTF l = new CCLabelTTF(subTitle, subtitle(), 16); AddChild(l, 1); l.Position = new CCPoint(s.Width / 2, s.Height - 80); } CCMenuItemImage item1 = new CCMenuItemImage("Images/b1.png", "Images/b2.png", backCallback); CCMenuItemImage item2 = new CCMenuItemImage("Images/r1.png", "Images/r2.png", restartCallback); CCMenuItemImage item3 = new CCMenuItemImage("Images/f1.png", "Images/f2.png", nextCallback); CCMenu menu = new CCMenu(item1, item2, item3); menu.Position = new CCPoint(0, 0); item1.Position = new CCPoint(s.Width / 2 - 100, 30); item2.Position = new CCPoint(s.Width / 2, 30); item3.Position = new CCPoint(s.Width / 2 + 100, 30); AddChild(menu, 1); }
public LabelTTFChinese() { CCSize size = CCDirector.SharedDirector.WinSize; CCLabelTTF pLable = new CCLabelTTF("中国", "Marker Felt", 30); pLable.Position = new CCPoint(size.Width / 2, size.Height / 2); AddChild(pLable); }
public override void OnEnter() { // // This test MUST be done in 'onEnter' and not on 'init' // otherwise the paused action will be resumed at 'onEnter' time // base.OnEnter(); CCSize s = CCDirector.SharedDirector.WinSize; CCLabelTTF l = new CCLabelTTF("After 5 seconds grossini should move", "arial", 16); AddChild(l); l.Position = (new CCPoint(s.Width / 2, 245)); // // Also, this test MUST be done, after [super onEnter] // CCSprite grossini = new CCSprite(s_pPathGrossini); AddChild(grossini, 0, kTagGrossini); grossini.Position = (new CCPoint(200, 200)); CCAction action = new CCMoveBy (1, new CCPoint(150, 0)); CCDirector.SharedDirector.ActionManager.AddAction(action, grossini, true); Schedule(unpause, 3); }
public override bool Init() { base.Init(); CCSize s = CCDirector.SharedDirector.WinSize; var label = new CCLabelTTF(title(), "arial", 32); AddChild(label, 1); label.Position = (new CCPoint(s.Width / 2, s.Height - 50)); string subtitle_ = subtitle(); if (subtitle_.Length > 0) { var l = new CCLabelTTF(subtitle_, "arial", 16); AddChild(l, 1); l.Position = (new CCPoint(s.Width / 2, s.Height - 80)); } var item1 = new CCMenuItemImage(TestResource.s_pPathB1, TestResource.s_pPathB2, backCallback); var item2 = new CCMenuItemImage(TestResource.s_pPathR1, TestResource.s_pPathR2, restartCallback); var item3 = new CCMenuItemImage(TestResource.s_pPathF1, TestResource.s_pPathF2, nextCallback); var menu = new CCMenu(item1, item2, item3); menu.Position = new CCPoint(0, 0); item1.Position = new CCPoint(s.Width / 2 - 100, 30); item2.Position = new CCPoint(s.Width / 2, 30); item3.Position = new CCPoint(s.Width / 2 + 100, 30); AddChild(menu, 1); return true; }
public override void OnEnter() { base.OnEnter(); CCSize s = CCDirector.SharedDirector.WinSize; CCLabelTTF label = new CCLabelTTF(title(), "arial", 28); AddChild(label, 1); label.Position = new CCPoint(s.Width / 2, s.Height - 50); string strSubtitle = subtitle(); if (strSubtitle != null) { CCLabelTTF l = new CCLabelTTF(strSubtitle, "arial", 16); AddChild(l, 1); l.Position = new CCPoint(s.Width / 2, s.Height - 80); } CCMenuItemImage item1 = new CCMenuItemImage(TestResource.s_pPathB1, TestResource.s_pPathB2, backCallback); CCMenuItemImage item2 = new CCMenuItemImage(TestResource.s_pPathR1, TestResource.s_pPathR2, restartCallback); CCMenuItemImage item3 = new CCMenuItemImage(TestResource.s_pPathF1, TestResource.s_pPathF2, nextCallback); CCMenu menu = new CCMenu(item1, item2, item3); menu.Position = new CCPoint(); item1.Position = new CCPoint(s.Width / 2 - 100, 30); item2.Position = new CCPoint(s.Width / 2, 30); item3.Position = new CCPoint(s.Width / 2 + 100, 30); AddChild(menu, 1); }
public GitHubIssue5() { CCSize s = CCDirector.SharedDirector.WinSize; _TestLabel = new CCLabelTTF("", "Arial", 10); AddChild(_TestLabel); _TestLabel.Position = new CCPoint(s.Width / 2, s.Height / 4 * 2); }
public GameOverLayer(int score, int remoteScore) { TouchEnabled = true; string scoreMessage = String.Format ("Game Over. You collected {0} bananas \r\n Opponent collected {1} bananas!", score, remoteScore); var scoreLabel = new CCLabelTTF (scoreMessage, "MarkerFelt", 22) { Position = new CCPoint( CCDirector.SharedDirector.WinSize.Center.X, CCDirector.SharedDirector.WinSize.Center.Y + 50), Color = new CCColor3B (XNA.Color.Yellow) }; AddChild (scoreLabel); var playAgainLabel = new CCLabelTTF ("Tap to Play Again", "MarkerFelt", 22) { Position = CCDirector.SharedDirector.WinSize.Center, Color = new CCColor3B (XNA.Color.Green) }; AddChild (playAgainLabel); Color = new CCColor3B (XNA.Color.Black); Opacity = 255; // Clean up the room from the server if (Context.isRoomCreator) { WarpClient.GetInstance ().DeleteRoom (Context.gameRoomId); } }
/** Initializes a switch with a mask sprite, on/off sprites for on/off states, a thumb sprite and an on/off labels. */ protected virtual bool InitWithMaskSprite(CCSprite maskSprite, CCSprite onSprite, CCSprite offSprite, CCSprite thumbSprite, CCLabelTTF onLabel, CCLabelTTF offLabel) { if (base.Init()) { Debug.Assert(maskSprite != null, "Mask must not be nil."); Debug.Assert(onSprite != null, "onSprite must not be nil."); Debug.Assert(offSprite != null, "offSprite must not be nil."); Debug.Assert(thumbSprite != null, "thumbSprite must not be nil."); TouchEnabled = true; _on = true; _switchSprite = new CCControlSwitchSprite(); _switchSprite.InitWithMaskSprite(maskSprite, onSprite, offSprite, thumbSprite, onLabel, offLabel); _switchSprite.Position = new CCPoint(_switchSprite.ContentSize.Width / 2, _switchSprite.ContentSize.Height / 2); AddChild(_switchSprite); IgnoreAnchorPointForPosition = false; AnchorPoint = new CCPoint(0.5f, 0.5f); ContentSize = _switchSprite.ContentSize; return true; } return false; }
public virtual void setSceneTitleLabel(CCLabelTTF var) { if (m_pSceneTitleLabel != var) { m_pSceneTitleLabel = var; } }
public override void OnEnter() { base.OnEnter(); CCSize s = CCDirector.SharedDirector.WinSize; CCLabelTTF label = new CCLabelTTF(title(), "arial", 28); AddChild(label, 1); label.Position = new CCPoint(s.Width / 2, s.Height - 50); string strSubtitle = subtitle(); if (!string.IsNullOrEmpty(strSubtitle)) { CCLabelTTF l = new CCLabelTTF(strSubtitle, "arial", 16); //CCLabelTTF l = CCLabelTTF.labelWithString(strSubtitle, "Thonburi", 16); AddChild(l, 1); l.Position = new CCPoint(s.Width / 2, s.Height - 80); } CCMenuItemImage item1 = new CCMenuItemImage("Images/b1", "Images/b2", backCallback); CCMenuItemImage item2 = new CCMenuItemImage("Images/r1", "Images/r2", restartCallback); CCMenuItemImage item3 = new CCMenuItemImage("Images/f1", "Images/f2", nextCallback); CCMenu menu = new CCMenu(item1, item2, item3); menu.Position = new CCPoint(); item1.Position = new CCPoint(s.Width / 2 - 100, 30); item2.Position = new CCPoint(s.Width / 2, 30); item3.Position = new CCPoint(s.Width / 2 + 100, 30); AddChild(menu, 1); }
public override void OnEnter() { base.OnEnter(); CCSize s = CCDirector.SharedDirector.WinSize; CCLabelTTF label = new CCLabelTTF(title(), "arial", 32); AddChild(label, 1); label.Position = (new CCPoint(s.Width / 2, s.Height - 50)); string subtitle_ = subtitle(); if (subtitle_.Length > 0) { CCLabelTTF l = new CCLabelTTF(subtitle_, "arial", 16); AddChild(l, 1); l.Position = (new CCPoint(s.Width / 2, s.Height - 80)); } CCMenuItemImage item1 = new CCMenuItemImage(s_pPathB1, s_pPathB2, (backCallback)); CCMenuItemImage item2 = new CCMenuItemImage(s_pPathR1, s_pPathR2, (restartCallback)); CCMenuItemImage item3 = new CCMenuItemImage(s_pPathF1, s_pPathF2, (nextCallback)); CCMenu menu = new CCMenu(item1, item2, item3); menu.Position = new CCPoint(0, 0); item1.Position = new CCPoint(s.Width / 2 - 100, 30); item2.Position = new CCPoint(s.Width / 2, 30); item3.Position = new CCPoint(s.Width / 2 + 100, 30); AddChild(menu, 1); }
public static CCMenuItem CreateScaledMenuItemLabel(CCSize buttonSize, int labelPadding, float strokeSize, CCColor3B textColor, CCColor3B strokeColor, CCColor3B backColor, string labelText, Action action) { var menuItem = action != null ? new CCMenuItem(o => action()) : new CCMenuItem(); var labelSize = new CCSize(buttonSize.Width - labelPadding, buttonSize.Height - labelPadding); // Add background var blockSprite = new CCSprite("images/Block_Back"); blockSprite.ScaleTo(buttonSize); blockSprite.Color = backColor; menuItem.AddChild(blockSprite); menuItem.ContentSize = buttonSize; // Add label var labelTtf = new CCLabelTTF(labelText, "arial-24", 10); labelTtf.Color = textColor; // Add Stroke to label // if (strokeSize > 0) labelTtf.AddStroke(strokeSize, strokeColor); if (labelTtf.ContentSize.Width > labelSize.Width) { labelTtf.ScaleTo(labelSize); } menuItem.AddChild(labelTtf); return menuItem; }
public RenderTextureZbuffer() { //this->setIsTouchEnabled(true); TouchEnabled = true; CCSize size = CCDirector.SharedDirector.WinSize; CCLabelTTF label = new CCLabelTTF("vertexZ = 50", "Marker Felt", 32); label.Position = new CCPoint(size.Width / 2, size.Height * 0.25f); AddChild(label); CCLabelTTF label2 = new CCLabelTTF("vertexZ = 0", "Marker Felt", 32); label2.Position = new CCPoint(size.Width / 2, size.Height * 0.5f); AddChild(label2); CCLabelTTF label3 = new CCLabelTTF("vertexZ = -50", "Marker Felt", 32); label3.Position = new CCPoint(size.Width / 2, size.Height * 0.75f); AddChild(label3); label.VertexZ = 50; label2.VertexZ = 0; label3.VertexZ = -50; CCSpriteFrameCache.SharedSpriteFrameCache.AddSpriteFramesWithFile("Images/bugs/circle.plist"); mgr = new CCSpriteBatchNode("Images/bugs/circle", 9); AddChild(mgr); sp1 = new CCSprite("Images/bugs/circle"); sp2 = new CCSprite("Images/bugs/circle"); sp3 = new CCSprite("Images/bugs/circle"); sp4 = new CCSprite("Images/bugs/circle"); sp5 = new CCSprite("Images/bugs/circle"); sp6 = new CCSprite("Images/bugs/circle"); sp7 = new CCSprite("Images/bugs/circle"); sp8 = new CCSprite("Images/bugs/circle"); sp9 = new CCSprite("Images/bugs/circle"); mgr.AddChild(sp1, 9); mgr.AddChild(sp2, 8); mgr.AddChild(sp3, 7); mgr.AddChild(sp4, 6); mgr.AddChild(sp5, 5); mgr.AddChild(sp6, 4); mgr.AddChild(sp7, 3); mgr.AddChild(sp8, 2); mgr.AddChild(sp9, 1); sp1.VertexZ = 400; sp2.VertexZ = 300; sp3.VertexZ = 200; sp4.VertexZ = 100; sp5.VertexZ = 0; sp6.VertexZ = -100; sp7.VertexZ = -200; sp8.VertexZ = -300; sp9.VertexZ = -400; sp9.Scale = 2; sp9.Color = CCTypes.CCYellow; }
public TextLayer() { InitWithColor(CCTypes.CreateColor(32, 32, 32, 255)); float x, y; CCSize size = CCDirector.SharedDirector.WinSize; x = size.Width; y = size.Height; CCNode node = new CCNode (); CCActionInterval effect = getAction(); node.RunAction(effect); AddChild(node, 0, EffectTestScene.kTagBackground); CCSprite bg = new CCSprite(TestResource.s_back3); node.AddChild(bg, 0); bg.AnchorPoint = new CCPoint(0.5f, 0.5f); bg.Position = new CCPoint(size.Width / 2, size.Height / 2); CCSprite grossini = new CCSprite(TestResource.s_pPathSister2); node.AddChild(grossini, 1); grossini.Position = new CCPoint(x / 3, y / 2); CCActionInterval sc = new CCScaleBy(2, 5); CCFiniteTimeAction sc_back = sc.Reverse(); grossini.RunAction(new CCRepeatForever ((CCActionInterval)(CCSequence.FromActions(sc, sc_back)))); //grossini.runAction(effect); CCSprite tamara = new CCSprite(TestResource.s_pPathSister1); node.AddChild(tamara, 1); tamara.Position = new CCPoint(2 * x / 3, y / 2); CCActionInterval sc2 = new CCScaleBy(2, 5); CCFiniteTimeAction sc2_back = sc2.Reverse(); tamara.RunAction(new CCRepeatForever ((CCActionInterval)(CCSequence.FromActions(sc2, sc2_back)))); CCLabelTTF label = new CCLabelTTF(EffectTestScene.effectsList[EffectTestScene.actionIdx], "arial", 32); label.Position = new CCPoint(x / 2, y - 80); AddChild(label); label.Tag = EffectTestScene.kTagLabel; CCMenuItemImage item1 = new CCMenuItemImage(TestResource.s_pPathB1, TestResource.s_pPathB2, backCallback); CCMenuItemImage item2 = new CCMenuItemImage(TestResource.s_pPathR1, TestResource.s_pPathR2, restartCallback); CCMenuItemImage item3 = new CCMenuItemImage(TestResource.s_pPathF1, TestResource.s_pPathF2, nextCallback); CCMenu menu = new CCMenu(item1, item2, item3); menu.Position = new CCPoint(0, 0); item1.Position = new CCPoint(size.Width / 2 - 100, 30); item2.Position = new CCPoint(size.Width / 2, 30); item3.Position = new CCPoint(size.Width / 2 + 100, 30); AddChild(menu, 1); Schedule(checkAnim); }
public override void OnEnter() { base.OnEnter(); float x, y; CCSize size = CCDirector.SharedDirector.WinSize; x = size.Width; y = size.Height; CCSprite bg = new CCSprite("Images/background3"); AddChild(bg, 0, EffectAdvanceScene.kTagBackground); bg.Position = new CCPoint(x / 2, y / 2); grossini = new CCSprite("Images/grossinis_sister2"); bg.AddChild(grossini, 1, EffectAdvanceScene.kTagSprite1); grossini.Position = new CCPoint(x / 3.0f, 200); CCActionInterval sc = new CCScaleBy(2, 5); CCFiniteTimeAction sc_back = sc.Reverse(); grossini.RunAction(new CCRepeatForever ((CCActionInterval)(CCSequence.FromActions(sc, sc_back)))); tamara = new CCSprite("Images/grossinis_sister1"); bg.AddChild(tamara, 1, EffectAdvanceScene.kTagSprite2); tamara.Position = new CCPoint(2 * x / 3.0f, 200); CCActionInterval sc2 = new CCScaleBy(2, 5); CCFiniteTimeAction sc2_back = sc2.Reverse(); tamara.RunAction(new CCRepeatForever ((CCActionInterval)(CCSequence.FromActions(sc2, sc2_back)))); CCLabelTTF label = new CCLabelTTF(title(), "arial", 28); label.Position = new CCPoint(x / 2, y - 80); AddChild(label); label.Tag = EffectAdvanceScene.kTagLabel; string strSubtitle = subtitle(); if (strSubtitle != null) { CCLabelTTF l = new CCLabelTTF(strSubtitle, "arial", 16); AddChild(l, 101); l.Position = new CCPoint(size.Width / 2, size.Height - 80); } CCMenuItemImage item1 = new CCMenuItemImage("Images/b1", "Images/b2", backCallback); CCMenuItemImage item2 = new CCMenuItemImage("Images/r1", "Images/r2", restartCallback); CCMenuItemImage item3 = new CCMenuItemImage("Images/f1", "Images/f2", nextCallback); CCMenu menu = new CCMenu(item1, item2, item3); menu.Position = new CCPoint(0, 0); item1.Position = new CCPoint(size.Width / 2 - 100, 30); item2.Position = new CCPoint(size.Width / 2, 30); item3.Position = new CCPoint(size.Width / 2 + 100, 30); AddChild(menu, 1); }
public bool InitWithString(string value, Action<object> selector) { //CCAssert( value != NULL && strlen(value) != 0, "Value length must be greater than 0"); m_strFontName = _fontName; m_uFontSize = _fontSize; CCLabelTTF label = new CCLabelTTF(value, m_strFontName, m_uFontSize); base.InitWithLabel(label, selector); return true; }
public TextLayer() { InitWithColor(CCTypes.CreateColor(32, 32, 32, 255)); var node = new CCNode(); CCActionInterval effect = getAction(); node.RunAction(effect); AddChild(node, 0, EffectTestScene.kTagBackground); var bg = new CCSprite(TestResource.s_back3); node.AddChild(bg, 0); bg.AnchorPoint = new CCPoint(0.5f, 0.5f); bg.Position = CCVisibleRect.Center; var grossini = new CCSprite(TestResource.s_pPathSister2); node.AddChild(grossini, 1); grossini.Position = new CCPoint(CCVisibleRect.Left.X + CCVisibleRect.VisibleRect.Size.Width / 3, CCVisibleRect.Center.Y); CCActionInterval sc = new CCScaleBy(2, 5); CCFiniteTimeAction sc_back = sc.Reverse(); grossini.RunAction(new CCRepeatForever((new CCSequence(sc, sc_back)))); var tamara = new CCSprite(TestResource.s_pPathSister1); node.AddChild(tamara, 1); tamara.Position = new CCPoint(CCVisibleRect.Left.X + 2 * CCVisibleRect.VisibleRect.Size.Width / 3, CCVisibleRect.Center.Y); CCActionInterval sc2 = new CCScaleBy(2, 5); CCFiniteTimeAction sc2_back = sc2.Reverse(); tamara.RunAction(new CCRepeatForever((new CCSequence(sc2, sc2_back)))); var label = new CCLabelTTF(EffectTestScene.effectsList[EffectTestScene.actionIdx], "arial", 32); label.Position = new CCPoint(CCVisibleRect.Center.X, CCVisibleRect.Top.Y - 80); AddChild(label); label.Tag = EffectTestScene.kTagLabel; var item1 = new CCMenuItemImage(TestResource.s_pPathB1, TestResource.s_pPathB2, backCallback); var item2 = new CCMenuItemImage(TestResource.s_pPathR1, TestResource.s_pPathR2, restartCallback); var item3 = new CCMenuItemImage(TestResource.s_pPathF1, TestResource.s_pPathF2, nextCallback); var menu = new CCMenu(item1, item2, item3); menu.Position = CCPoint.Zero; item1.Position = new CCPoint(CCVisibleRect.Center.X - item2.ContentSize.Width * 2, CCVisibleRect.Bottom.Y + item2.ContentSize.Height / 2); item2.Position = new CCPoint(CCVisibleRect.Center.X, CCVisibleRect.Bottom.Y + item2.ContentSize.Height / 2); item3.Position = new CCPoint(CCVisibleRect.Center.X + item2.ContentSize.Width * 2, CCVisibleRect.Bottom.Y + item2.ContentSize.Height / 2); AddChild(menu, 1); Schedule(checkAnim); }
public TTFFontInit() { CCSize s = CCDirector.SharedDirector.WinSize; var font = new CCLabelTTF(); font.Init(); font.FontName = "Marker Felt"; font.FontSize = 38; font.Text = ("It is working!"); AddChild(font); font.Position = new CCPoint(s.Width / 2, s.Height / 4 * 2); }
public LabelTTFMultiline() { CCSize s = CCDirector.SharedDirector.WinSize; // CCLabelBMFont CCLabelTTF center = new CCLabelTTF("word wrap \"testing\" (bla0) bla1 'bla2' [bla3] (bla4) {bla5} {bla6} [bla7] (bla8) [bla9] 'bla0' \"bla1\"", "Paint Boy", 32, new CCSize(s.Width / 2, 200), CCTextAlignment.CCTextAlignmentCenter); center.Position = new CCPoint(s.Width / 2, 150); AddChild(center); }
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 = new CCMenu(null); CCSize s = CCDirector.SharedDirector.WinSize; m_nTestCount = testItems.Count<string>(); for (int i = 0; i < m_nTestCount; ++i) { CCLabelTTF label = new CCLabelTTF(testItems[i], "arial", 24); CCMenuItemLabel pMenuItem = new CCMenuItemLabel(label, 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.TouchEnabled = true; // preload background music and effect CCSimpleAudioEngine.SharedEngine.PreloadBackgroundMusic(CCFileUtils.FullPathFromRelativePath(MUSIC_FILE)); CCSimpleAudioEngine.SharedEngine.PreloadEffect(CCFileUtils.FullPathFromRelativePath(EFFECT_FILE)); // set default volume CCSimpleAudioEngine.SharedEngine.EffectsVolume = 0.5f; CCSimpleAudioEngine.SharedEngine.BackgroundMusicVolume = 0.5f; }
public GameStartLayer() { TouchEnabled = true; statusLabel = new CCLabelTTF (status, "MarkerFelt", 22) { Position = CCDirector.SharedDirector.WinSize.Center, Color = new CCColor3B (XNA.Color.Yellow) }; AddChild(statusLabel); Color = new CCColor3B (XNA.Color.ForestGreen); Opacity = 255; }
public override void OnEnter() { base.OnEnter(); float x, y; CCSize size = CCDirector.SharedDirector.WinSize; x = size.Width; y = size.Height; //CCMutableArray *array = [UIFont familyNames]; //for( CCString *s in array ) // NSLog( s ); CCLabelTTF label = new CCLabelTTF("cocos2d", "arial", 64); label.Position = new CCPoint(x / 2, y / 2); AddChild(label); }
public override bool Init() { if (base.Init()) { CCSize screenSize = CCDirector.SharedDirector.WinSize; CCNode layer = new CCNode (); layer.Position = new CCPoint(screenSize.Width / 2, screenSize.Height / 2); AddChild(layer, 1); float layer_width = 0.0f; // Add the black background for the text CCScale9Sprite background = new CCScale9SpriteFile("extensions/buttonBackground"); background.ContentSize = new CCSize(80, 50); background.Position = new CCPoint(layer_width + background.ContentSize.Width / 2.0f, 0); layer.AddChild(background); layer_width += background.ContentSize.Width; m_pDisplayValueLabel = new CCLabelTTF("#color", "Arial", 30); m_pDisplayValueLabel.Position = background.Position; layer.AddChild(m_pDisplayValueLabel); // Create the switch CCControlSwitch switchControl = new CCControlSwitch ( new CCSprite("extensions/switch-mask"), new CCSprite("extensions/switch-on"), new CCSprite("extensions/switch-off"), new CCSprite("extensions/switch-thumb"), new CCLabelTTF("On", "Arial", 16), new CCLabelTTF("Off", "Arial", 16) ); switchControl.Position = new CCPoint(layer_width + 10 + switchControl.ContentSize.Width / 2, 0); layer.AddChild(switchControl); switchControl.AddTargetWithActionForControlEvents(this, valueChanged, CCControlEvent.ValueChanged); // Set the layer size layer.ContentSize = new CCSize(layer_width, 0); layer.AnchorPoint = new CCPoint(0.5f, 0.5f); // Update the value label valueChanged(switchControl, CCControlEvent.ValueChanged); return true; } return false; }
public override bool Init() { if (base.Init()) { CCSize screenSize = CCDirector.SharedDirector.WinSize; CCNode layer = new CCNode(); layer.Position = new CCPoint(screenSize.Width / 2, screenSize.Height / 2); AddChild(layer, 1); float layer_width = 0; // Create the colour picker CCControlColourPicker colourPicker = new CCControlColourPicker(); colourPicker.Color = new CCColor3B(37, 46, 252); colourPicker.Position = new CCPoint(colourPicker.ContentSize.Width / 2, 0); // Add it to the layer layer.AddChild(colourPicker); // Add the target-action pair colourPicker.AddTargetWithActionForControlEvents(this, ColourValueChanged, CCControlEvent.ValueChanged); layer_width += colourPicker.ContentSize.Width; // Add the black background for the text CCScale9Sprite background = new CCScale9SpriteFile("extensions/buttonBackground.png"); background.ContentSize = new CCSize(150, 50); background.Position = new CCPoint(layer_width + background.ContentSize.Width / 2.0f, 0); layer.AddChild(background); layer_width += background.ContentSize.Width; _colorLabel = new CCLabelTTF("#color", "Arial", 26); _colorLabel.Position = background.Position; layer.AddChild(_colorLabel); // Set the layer size layer.ContentSize = new CCSize(layer_width, 0); layer.AnchorPoint = new CCPoint(0.5f, 0.5f); // Update the color text ColourValueChanged(colourPicker, CCControlEvent.ValueChanged); return true; } return false; }
public override bool Init() { if (base.Init()) { CCSize screenSize = CCDirector.SharedDirector.WinSize; var layer = new CCNode(); layer.Position = new CCPoint(screenSize.Width / 2, screenSize.Height / 2); AddChild(layer, 1); double layer_width = 0; // Add the black background for the text CCScale9Sprite background = new CCScale9SpriteFile("extensions/buttonBackground.png"); background.ContentSize = new CCSize(80, 50); background.Position = new CCPoint((float) layer_width + background.ContentSize.Width / 2.0f, 0); layer.AddChild(background); layer_width += background.ContentSize.Width; DisplayValueLabel = new CCLabelTTF("", "Arial", 30); _displayValueLabel.Position = background.Position; layer.AddChild(_displayValueLabel); // Add the slider var potentiometer = new CCControlPotentiometer("extensions/potentiometerTrack.png" , "extensions/potentiometerProgress.png" , "extensions/potentiometerButton.png"); potentiometer.Position = new CCPoint((float) layer_width + 10 + potentiometer.ContentSize.Width / 2, 0); // When the value of the slider will change, the given selector will be call potentiometer.AddTargetWithActionForControlEvents(this, ValueChanged, CCControlEvent.ValueChanged); layer.AddChild(potentiometer); layer_width += potentiometer.ContentSize.Width; // Set the layer size layer.ContentSize = new CCSize((float) layer_width, 0); layer.AnchorPoint = new CCPoint(0.5f, 0.5f); // Update the value label ValueChanged(potentiometer, CCControlEvent.ValueChanged); return true; } return false; }
public IntroLayer() { // create and initialize a Label var label = new CCLabelTTF("Hello Cocos2D-XNA", "MarkerFelt", 22); // position the label on the center of the screen label.Position = CCDirector.SharedDirector.WinSize.Center; // add the label as a child to this Layer AddChild(label); // setup our color for the background Color = new CCColor3B(Microsoft.Xna.Framework.Color.Blue); Opacity = 255; }
public override void OnEnter() { base.OnEnter(); AccelerometerEnabled = true; CCSize s = CCDirector.SharedDirector.WinSize; CCLabelTTF label = new CCLabelTTF(title(), "Arial", 32); AddChild(label, 1); label.Position = new CCPoint(s.Width / 2, s.Height - 50); m_pBall = new CCSprite("Images/ball"); m_pBall.Position = s.Center; AddChild(m_pBall); }
/** Creates and return a button with a default background and title color. */ public CCControlButton standardButtonWithTitle(string title) { /** Creates and return a button with a default background and title color. */ var backgroundButton = new CCScale9SpriteFile("extensions/button"); var backgroundHighlightedButton = new CCScale9SpriteFile("extensions/buttonHighlighted"); var titleButton = new CCLabelTTF(title, "Arial", 30); titleButton.Color = new CCColor3B(159, 168, 176); var button = new CCControlButton(titleButton, backgroundButton); button.SetBackgroundSpriteForState(backgroundHighlightedButton, CCControlState.Highlighted); button.SetTitleColorForState(CCTypes.CCWhite, CCControlState.Highlighted); return button; }
public GameLevel () { layerInstance = this; // enable touches #if XBOX || OUYA TouchEnabled = false; GamePadEnabled = true; #else TouchEnabled = true; #endif // enable accelerometer AccelerometerEnabled = false; // ask director for the window size var screenSize = CCDirector.SharedDirector.WinSize; // create and initialize a Label var label = new CCLabelTTF("Game Layer", "MarkerFelt", 22); // position the label on the center of the screen label.Position = CCDirector.SharedDirector.WinSize.Center; // add the label as a child to this Layer AddChild(label); menuStartPosition = new CCPoint( 70 , screenSize.Height-24); var gameMenuLabel = new CCLabelTTF("Game Menu", "MarkerFelt", 18); var button1 = new CCMenuItemLabel (gameMenuLabel, ShowMenu); MenuButton = new CCMenu (button1); MenuButton.Position = menuStartPosition; AddChild (MenuButton, 10); openWithMenuInsteadOfGame = false; if (GameData.SharedData.FirstRunEver && openWithMenuInsteadOfGame) { CCLog.Log("First run ever"); Schedule(ShowMenuFromSelector, 2f); GameData.SharedData.FirstRunEver = false; } }
public void updateStrings(float dt) { CCLabelBMFont label1 = (CCLabelBMFont)GetChildByTag((int)TagSprite.kTagBitmapAtlas1); CCLabelTTF label2 = (CCLabelTTF)GetChildByTag((int)TagSprite.kTagBitmapAtlas2); CCLabelAtlas label3 = (CCLabelAtlas)GetChildByTag((int)TagSprite.kTagBitmapAtlas3); if (!setEmpty) { label1.Label = ("not empty"); label2.Label = ("not empty"); label3.Label = ("hi"); setEmpty = true; } else { label1.Label = (""); label2.Label = (""); label3.Label = (""); setEmpty = false; } }
public virtual bool onTextFieldDeleteBackward(CCTextFieldTTF pSender, string delText, int nLen) { // create a delete text sprite and do some action CCLabelTTF label = new CCLabelTTF(delText, TextInputTestScene.FONT_NAME, TextInputTestScene.FONT_SIZE); this.AddChild(label); // move the sprite to fly out CCPoint beginPos = pSender.Position; CCSize textfieldSize = pSender.ContentSize; CCSize labelSize = label.ContentSize; beginPos.X += (textfieldSize.Width - labelSize.Width) / 2.0f; int RAND_MAX = 32767; CCRandom rand = new CCRandom(); CCSize winSize = CCDirector.SharedDirector.WinSize; CCPoint endPos = new CCPoint(-winSize.Width / 4.0f, winSize.Height * (0.5f + (float)CCRandom.Next() / (2.0f * RAND_MAX))); float duration = 1; float rotateDuration = 0.2f; int repeatTime = 5; label.Position = beginPos; CCAction seq = CCSequence.FromActions( CCSpawn.FromActions( new CCMoveTo(duration, endPos), new CCRepeat( new CCRotateBy(rotateDuration, (CCRandom.Next() % 2 > 0) ? 360 : -360), (uint)repeatTime), new CCFadeOut(duration)), new CCCallFuncN(callbackRemoveNodeWhenDidAction)); label.RunAction(seq); return(false); }
public void CreateStatsLabel() { if (!m_FailedToCreateStatsLabels) { try { int fontSize = (int)(m_obWinSizeInPoints.Height / 320.0f * 24); m_pFPSLabel = new CCLabelTTF("00.0", "Arial", 24); m_pFPSLabel.Scale = m_obWinSizeInPoints.Height / 320.0f; // Use 320 here b/c we are optimizing at that scale. m_pSPFLabel = new CCLabelTTF("0.000", "Arial", 24); m_pSPFLabel.Scale = m_obWinSizeInPoints.Height / 320.0f; m_pDrawsLabel = new CCLabelTTF("000", "Arial", 24); m_pDrawsLabel.Scale = m_obWinSizeInPoints.Height / 320.0f; //CCTexture2D::setDefaultAlphaPixelFormat(currentFormat); var pos = CCDirector.SharedDirector.VisibleOrigin; CCSize contentSize = m_pDrawsLabel.ContentSize; m_pDrawsLabel.Position = new CCPoint(contentSize.Width / 2, contentSize.Height * 5 / 2) + pos; contentSize = m_pSPFLabel.ContentSize; m_pSPFLabel.Position = new CCPoint(contentSize.Width / 2, contentSize.Height * 3 / 2) + pos; contentSize = m_pFPSLabel.ContentSize; m_pFPSLabel.Position = new CCPoint(contentSize.Width / 2, contentSize.Height / 2) + pos; } catch (Exception ex) { CCLog.Log("Failed to create the stats labels."); #if DEBUG CCLog.Log(ex.ToString()); #endif m_FailedToCreateStatsLabels = true; m_bDisplayStats = false; } } }
protected void RecreateLabel() { CCLabelTTF label = new CCLabelTTF((m_pLabel as ICCLabelProtocol).Text, m_strFontName, m_uFontSize); Label = label; }
protected virtual bool InitWithBackgroundSprite(CCScale9Sprite sprite) { CCLabelTTF label = new CCLabelTTF("", "arial", 30); return(InitWithLabelAndBackgroundSprite(label, sprite)); }
protected virtual bool InitWithTitleAndFontNameAndFontSize(string title, string fontName, float fontSize) { CCLabelTTF label = new CCLabelTTF(title, fontName, fontSize); return(InitWithLabelAndBackgroundSprite(label, new CCScale9Sprite())); }
/** Creates a switch with a mask sprite, on/off sprites for on/off states, a thumb sprite and an on/off labels. */ public CCControlSwitch(CCSprite maskSprite, CCSprite onSprite, CCSprite offSprite, CCSprite thumbSprite, CCLabelTTF onLabel, CCLabelTTF offLabel) { InitWithMaskSprite(maskSprite, onSprite, offSprite, thumbSprite, onLabel, offLabel); }
/** Initializes a switch with a mask sprite, on/off sprites for on/off states, a thumb sprite and an on/off labels. */ protected virtual bool InitWithMaskSprite(CCSprite maskSprite, CCSprite onSprite, CCSprite offSprite, CCSprite thumbSprite, CCLabelTTF onLabel, CCLabelTTF offLabel) { if (base.Init()) { Debug.Assert(maskSprite != null, "Mask must not be nil."); Debug.Assert(onSprite != null, "onSprite must not be nil."); Debug.Assert(offSprite != null, "offSprite must not be nil."); Debug.Assert(thumbSprite != null, "thumbSprite must not be nil."); TouchEnabled = true; _on = true; _switchSprite = new CCControlSwitchSprite(); _switchSprite.InitWithMaskSprite(maskSprite, onSprite, offSprite, thumbSprite, onLabel, offLabel); _switchSprite.Position = new CCPoint(_switchSprite.ContentSize.Width / 2, _switchSprite.ContentSize.Height / 2); AddChild(_switchSprite); IgnoreAnchorPointForPosition = false; AnchorPoint = new CCPoint(0.5f, 0.5f); ContentSize = _switchSprite.ContentSize; return(true); } return(false); }