public LabelFNTOldNew() { // CCLabel Bitmap Font label1 = new CCLabel("Bitmap Font Label Test", "fonts/arial-unicode-26.fnt"); label1.Scale = 2; label1.Color = CCColor3B.White; AddChild(label1); label2 = new CCLabelBMFont("Bitmap Font Label Test", "fonts/arial-unicode-26.fnt"); label2.Scale = 2; label2.Color = CCColor3B.Red; AddChild(label2); drawNode = new CCDrawNode(); AddChild(drawNode); var touchListener = new CCEventListenerTouchAllAtOnce(); touchListener.OnTouchesEnded = (touches, touchEvent) => { var location = touches[0].Location; if (label1.BoundingBoxTransformedToWorld.ContainsPoint(location)) CCLog.Log("Hit"); }; AddEventListener(touchListener); }
public BitmapFontMultiLine() { CCSize s; // Left label1 = new CCLabelBMFont("Multi line\nLeft", "fonts/bitmapFontTest3.fnt"); label1.AnchorPoint = new CCPoint(0, 0); AddChild(label1, 0, (int)TagSprite.kTagBitmapAtlas1); s = label1.ContentSize; //CCLOG("content size: %.2fx%.2f", s.width, s.height); CCLog.Log("content size: {0,0:2f}x{1,0:2f}", s.Width, s.Height); // Center label2 = new CCLabelBMFont("Multi line\nCenter", "fonts/bitmapFontTest3.fnt"); label2.AnchorPoint = new CCPoint(0.5f, 0.5f); AddChild(label2, 0, (int)TagSprite.kTagBitmapAtlas2); s = label2.ContentSize; //CCLOG("content size: %.2fx%.2f", s.width, s.height); CCLog.Log("content size: {0,0:2f}x{1,0:2f}", s.Width, s.Height); // right label3 = new CCLabelBMFont("Multi line\nRight\nThree lines Three", "fonts/bitmapFontTest3.fnt"); label3.AnchorPoint = new CCPoint(1, 1); AddChild(label3, 0, (int)TagSprite.kTagBitmapAtlas3); s = label3.ContentSize; //CCLOG("content size: %.2fx%.2f", s.width, s.height); }
public override void OnEnter() { base.OnEnter(); CCSize s = Layer.VisibleBoundsWorldspace.Size; CCLayerColor layer = new CCLayerColor(new CCColor4B(0xFF, 0x00, 0x00, 0x80)); layer.IgnoreAnchorPointForPosition = false; layer.Position = (new CCPoint(s.Width / 2, s.Height / 2)); AddChild(layer, 1, kTagLayer); // // Add two labels using BM label class // CCLabelBMFont var label1 = new CCLabelBMFont("LABEL1", "fonts/konqa32.fnt"); layer.AddChild(label1); label1.Position = new CCPoint(layer.ContentSize.Width / 2, layer.ContentSize.Height * 0.75f); var label2 = new CCLabelBMFont("LABEL2", "fonts/konqa32.fnt"); layer.AddChild(label2); label2.Position = new CCPoint(layer.ContentSize.Width / 2, layer.ContentSize.Height * 0.25f); // // Do the sequence of actions in the bug report layer.Visible = false; layer.RunActions(hide, scaleTo1, show, delay, scaleTo2, scaleTo3, scaleTo4, scaleTo5); }
public Atlas5() { label = new CCLabelBMFont("abcdefg", "fonts/bitmapFontTest4.fnt"); AddChild(label); label.AnchorPoint = CCPoint.AnchorMiddle; }
public IntervalLayer() { m_time0 = m_time1 = m_time2 = m_time3 = m_time4 = 0.0f; CCSize s = Layer.VisibleBoundsWorldspace.Size; // sun CCParticleSystem sun = new CCParticleSun(new CCPoint(s.Width / 2, s.Height / 2)); sun.Texture = CCTextureCache.SharedTextureCache.AddImage("Images/fire"); sun.Position = (new CCPoint(s.Width - 32, s.Height - 32)); sun.TotalParticles = 130; sun.Life = (0.6f); AddChild(sun); // timers m_label0 = new CCLabelBMFont("0", "fonts/bitmapFontTest4.fnt"); m_label1 = new CCLabelBMFont("0", "fonts/bitmapFontTest4.fnt"); m_label2 = new CCLabelBMFont("0", "fonts/bitmapFontTest4.fnt"); m_label3 = new CCLabelBMFont("0", "fonts/bitmapFontTest4.fnt"); m_label4 = new CCLabelBMFont("0", "fonts/bitmapFontTest4.fnt"); Schedule (); Schedule(step1); Schedule(step2, 0); Schedule(step3, 1.0f); Schedule(step4, 2.0f); m_label0.Position = new CCPoint(s.Width * 1 / 6, s.Height / 2); m_label1.Position = new CCPoint(s.Width * 2 / 6, s.Height / 2); m_label2.Position = new CCPoint(s.Width * 3 / 6, s.Height / 2); m_label3.Position = new CCPoint(s.Width * 4 / 6, s.Height / 2); m_label4.Position = new CCPoint(s.Width * 5 / 6, s.Height / 2); AddChild(m_label0); AddChild(m_label1); AddChild(m_label2); AddChild(m_label3); AddChild(m_label4); // Sprite CCSprite sprite = new CCSprite(s_pPathGrossini); sprite.Position = new CCPoint(40, 50); CCJumpBy jump = new CCJumpBy (3, new CCPoint(s.Width - 80, 0), 50, 4); AddChild(sprite); sprite.RunAction(new CCRepeatForever ( (CCFiniteTimeAction) (new CCSequence(jump, jump.Reverse()))) ); // pause button CCMenuItem item1 = new CCMenuItemFont("Pause", onPause); CCMenu menu = new CCMenu(item1); menu.Position = new CCPoint(s.Width / 2, s.Height - 50); AddChild(menu); }
public BMFontInit() { bmFont = new CCLabelBMFont(); //CCLabelBMFont* bmFont = [CCLabelBMFont create:@"Foo" fntFile:@"arial-unicode-26"]; bmFont.FntFile = "fonts/helvetica-32.fnt"; bmFont.Text = ("It is working!"); AddChild(bmFont); }
public Issue1343() { bmFont = new CCLabelBMFont(); bmFont.FntFile = "fonts/font-issue1343.fnt"; bmFont.Text = ("ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890abcdefghijklmnopqrstuvwxyz.,'"); AddChild(bmFont); bmFont.Scale = 0.3f; }
public LabelGlyphDesigner() { var layer = new CCLayerColor(new CCColor4B(128, 128, 128, 255)); AddChild(layer, -10); // CCLabelBMFont label1 = new CCLabelBMFont("Testing Glyph Designer", "fonts/futura-48.fnt"); AddChild(label1); }
public BMFontOneAtlas() { label1 = new CCLabelBMFont("This is Helvetica", "fonts/helvetica-32.fnt", CCLabelBMFont.AutomaticWidth, CCTextAlignment.Left, CCPoint.Zero); AddChild(label1); label2 = new CCLabelBMFont("And this is Geneva", "fonts/geneva-32.fnt", CCLabelBMFont.AutomaticWidth, CCTextAlignment.Left, new CCPoint(0, 128)); AddChild(label2); }
public Atlas6() { label1 = new CCLabelBMFont("FaFeFiFoFu", "fonts/bitmapFontTest5.fnt"); AddChild(label1); label1.AnchorPoint = CCPoint.AnchorMiddle; label2 = new CCLabelBMFont("fafefifofu", "fonts/bitmapFontTest5.fnt"); AddChild(label2); label2.AnchorPoint = CCPoint.AnchorMiddle; label3 = new CCLabelBMFont("aeiou", "fonts/bitmapFontTest5.fnt"); AddChild(label3); label3.AnchorPoint = CCPoint.AnchorMiddle; }
public override void OnEnter() { base.OnEnter(); var s = Layer.VisibleBoundsWorldspace.Size; var layer1 = new CCLayer(); var sister1 = new CCSprite("Images/grossinis_sister1.png"); var sister2 = new CCSprite("Images/grossinis_sister2.png"); var label = new CCLabelBMFont("Test", "fonts/bitmapFontTest.fnt"); // by default a CCLabelBMFont has IsColorModifiedByOpacity on by default if the // texture atlas is PreMultipliedAlpha. Label as used by Cocos2d-x by default has // this set to false. Maybe this is a bug in Cocos2d-x? label.IsColorModifiedByOpacity = false; layer1.AddChild(sister1); layer1.AddChild(sister2); layer1.AddChild(label); this.AddChild( layer1, 0, kTagLayer); sister1.Position= new CCPoint( s.Width*1/3, s.Height/2); sister2.Position = new CCPoint( s.Width*2/3, s.Height/2); label.Position = new CCPoint(s.Width / 2, s.Height / 2); // Define our delay time var delay = new CCDelayTime (1); layer1.RepeatForever( new CCFadeTo(4, 0), new CCFadeTo(4, 255), delay ); // We only have to define them once. var fadeTo11 = new CCFadeTo (2, 0); var fadeTo12 = new CCFadeTo (2, 255); sister1.RepeatForever( fadeTo11, fadeTo12, fadeTo11, fadeTo12, delay ); // Enable cascading in scene SetEnableRecursiveCascading(this, true); }
public AtlasFastBitmap() { // Upper Label for (int i = 0; i < 100; i++) { //char str[6] = {0}; string str; //sprintf(str, "-%d-", i); str = string.Format("-{0}-", i); var label = new CCLabelBMFont(str, "fonts/bitmapFontTest.fnt") { Tag = i + 100}; AddChild(label); label.AnchorPoint = CCPoint.AnchorMiddle; } }
public Atlas4() { m_time = 0; // Upper Label label = new CCLabelBMFont("Bitmap Font Atlas", "fonts/bitmapFontTest.fnt"); AddChild(label); label.AnchorPoint = CCPoint.AnchorMiddle; var BChar = (CCSprite)label[0]; var FChar = (CCSprite)label[7]; var AChar = (CCSprite)label[12]; var rotate = new CCRotateBy (2, 360); var rot_4ever = new CCRepeatForever (rotate); var scale = new CCScaleBy(2, 1.5f); var scale_back = scale.Reverse(); var scale_seq = new CCSequence(scale, scale_back); var scale_4ever = new CCRepeatForever (scale_seq); var jump = new CCJumpBy (0.5f, new CCPoint(), 60, 1); var jump_4ever = new CCRepeatForever (jump); var fade_out = new CCFadeOut (1); var fade_in = new CCFadeIn (1); var seq = new CCSequence(fade_out, fade_in); var fade_4ever = new CCRepeatForever (seq); BChar.RunAction(rot_4ever); BChar.RunAction(scale_4ever); FChar.RunAction(jump_4ever); AChar.RunAction(fade_4ever); // Bottom Label label2 = new CCLabelBMFont("00.0", "fonts/bitmapFontTest.fnt"); AddChild(label2, 0, (int)TagSprite.kTagBitmapAtlas2); var lastChar = (CCSprite)label2[3]; lastChar.RunAction(rot_4ever); //schedule( schedule_selector(Atlas4::step), 0.1f); base.Schedule(step, 0.1f); }
public AtlasBitmapColor() { label1 = new CCLabelBMFont("Blue", "fonts/bitmapFontTest5.fnt"); label1.Color = CCColor3B.Blue; AddChild(label1); label1.AnchorPoint = CCPoint.AnchorMiddle; label2 = new CCLabelBMFont("Red", "fonts/bitmapFontTest5.fnt"); AddChild(label2); label2.AnchorPoint = CCPoint.AnchorMiddle; label2.Color = CCColor3B.Red; label3 = new CCLabelBMFont("G", "fonts/bitmapFontTest5.fnt"); AddChild(label3); label3.AnchorPoint = CCPoint.AnchorMiddle; label3.Color = CCColor3B.Green; label3.Text = "Green"; }
public LabelsEmpty() { // CCLabelBMFont label1 = new CCLabelBMFont("", "fonts/bitmapFontTest3.fnt"); AddChild(label1, 0, (int)TagSprite.kTagBitmapAtlas1); // CCLabelTTF label2 = new CCLabelTtf("", "arial", 24); AddChild(label2, 0, (int)TagSprite.kTagBitmapAtlas2); // CCLabelAtlas label3 = new CCLabelAtlas("", "fonts/tuffy_bold_italic-charmap", 48, 64, ' '); AddChild(label3, 0, (int)TagSprite.kTagBitmapAtlas3); base.Schedule(updateStrings, 1.0f); setEmpty = false; }
protected override void AddedToScene() { base.AddedToScene(); var label = new CCLabelBMFont("Enable AtlasItem", "fonts/bitmapFontTest3.fnt"); var item1 = new CCMenuItemLabelBMFont(label, this.menuCallback2); CCMenuItemFont.FontSize = 28; CCMenuItemFont.FontName = "arial"; var item2 = new CCMenuItemFont("--- Go Back ---", this.menuCallback); // We do not have an HD version of the menuitemsprite so internally CocosSharp tries to convert our // rectangle coordinates passed to work with HD images so the coordinates are off. We will just // modify this here to make sure we have the correct sizes when they are passed. var spriteNormal = new CCSprite(s_MenuItem, new CCRect(0, 23 * 2, 115, 23)); var spriteSelected = new CCSprite(s_MenuItem, new CCRect(0, 23 * 1, 115, 23)); var spriteDisabled = new CCSprite(s_MenuItem, new CCRect(0, 23 * 0, 115, 23)); var item3 = new CCMenuItemImage(spriteNormal, spriteSelected, spriteDisabled, this.menuCallback3); m_disabledItem = item3; m_disabledItem.Enabled = false; var menu = new CCMenu(item1, item2, item3); menu.Position = new CCPoint(0, 0); var s = Layer.VisibleBoundsWorldspace.Size; item1.Position = new CCPoint(s.Width / 2 - 150, s.Height / 2); item2.Position = new CCPoint(s.Width / 2 - 200, s.Height / 2); item3.Position = new CCPoint(s.Width / 2, s.Height / 2 - 100); var jump = new CCJumpBy (3, new CCPoint(400, 0), 50, 4); item2.RepeatForever(jump, jump.Reverse()); var spin1 = new CCRotateBy (3, 360); item1.RepeatForever(spin1); item2.RepeatForever(spin1); item3.RepeatForever(spin1); AddChild(menu); }
public BMFontUnicode() { var data = CCFileUtils.GetFileData("fonts/strings.plist"); PlistDocument doc = new PlistDocument(data); var strings = doc.Root as PlistDictionary; string chinese = strings["chinese1"].AsString; string japanese = strings["japanese"].AsString; string spanish = strings["spanish"].AsString; label1 = new CCLabelBMFont(spanish, "fonts/arial-unicode-26.fnt", 200, CCTextAlignment.Left); AddChild(label1); label2 = new CCLabelBMFont(chinese, "fonts/arial-unicode-26.fnt"); AddChild(label2); label3 = new CCLabelBMFont(japanese, "fonts/arial-unicode-26.fnt"); AddChild(label3); }
public override void OnEnter() { base.OnEnter(); CCSize s = Layer.VisibleBoundsWorldspace.Size; // add title CCLabelTtf label = new CCLabelTtf(title(), "arial", 32); AddChild(label, 1); label.Position = new CCPoint(s.Width / 2, s.Height - 50); Schedule (); m_plabel = new CCLabelBMFont("00.0", "fonts/arial16.fnt"); m_plabel.Position = new CCPoint(s.Width / 2, s.Height / 2); AddChild(m_plabel); elapsedTime = 0; numberOfTouchesB = numberOfTouchesM = numberOfTouchesE = numberOfTouchesC = 0; }
public GameLayer() { gameSuspended = true; var batchnode = GetChildByTag((int)Tags.SpriteManager) as CCSpriteBatchNode; InitPlatforms(); var bird = new CCSprite(batchnode.Texture, new CCRect(608, 16, 44, 32)); batchnode.AddChild(bird, 4, (int)Tags.Bird); CCSprite bonus; for (int i = 0; i < (int)Bonus.NumBonuses; i++) { bonus = new CCSprite(batchnode.Texture, new CCRect(608 + i * 32, 256, 25, 25)); batchnode.AddChild(bonus, 4, (int)Tags.BomusStart + i); bonus.Visible = false; } var scoreLabel = new CCLabelBMFont("0", "Fonts/bitmapFont.fnt"); scoreLabel.Position = new CCPoint(160, 430); AddChild(scoreLabel, 5, (int)Tags.ScoreLabel); }
public Atlas3() { m_time = 0; Color = new CCColor3B(128, 128, 128); Opacity = 255; label1 = new CCLabelBMFont("Test", "fonts/bitmapFontTest2.fnt"); // testing anchors label1.AnchorPoint = CCPoint.AnchorLowerLeft; AddChild(label1, 0, (int)TagSprite.kTagBitmapAtlas1); var fade = new CCFadeOut (1.0f); var fade_in = fade.Reverse(); label1.RepeatForever ( fade, fade_in); // VERY IMPORTANT // color and opacity work OK because bitmapFontAltas2 loads a BMP image (not a PNG image) // If you want to use both opacity and color, it is recommended to use NON premultiplied images like BMP images // Of course, you can also tell XCode not to compress PNG images, but I think it doesn't work as expected label2 = new CCLabelBMFont("Test", "fonts/bitmapFontTest2.fnt"); // testing anchors label2.AnchorPoint = CCPoint.AnchorMiddle; label2.Color = CCColor3B.Red; AddChild(label2, 0, (int)TagSprite.kTagBitmapAtlas2); label2.RepeatForever( new CCTintTo (1, 255, 0, 0), new CCTintTo (1, 0, 255, 0), new CCTintTo (1, 0, 0, 255)); label3 = new CCLabelBMFont("Test", "fonts/bitmapFontTest2.fnt"); // testing anchors label3.AnchorPoint = CCPoint.AnchorUpperRight; AddChild(label3, 0, (int)TagSprite.kTagBitmapAtlas3); base.Schedule(step); }
public override void OnEnter() { base.OnEnter(); CCSize s = Layer.VisibleBoundsWorldspace.Size; var layer1 = new CCLayerColor(new CCColor4B(0xFF, 0xFF, 0x00, 0x80)); layer1.IgnoreAnchorPointForPosition = false; layer1.Position = (new CCPoint(s.Width / 2, s.Height / 2)); layer1.ChildClippingMode = CCClipMode.Bounds; AddChild(layer1, 1); s = layer1.ContentSize; m_pInnerLayer = new CCLayerColor(new CCColor4B(0xFF, 0x00, 0x00, 0x80)); m_pInnerLayer.IgnoreAnchorPointForPosition = false; m_pInnerLayer.Position = (new CCPoint(s.Width / 2, s.Height / 2)); m_pInnerLayer.ChildClippingMode = CCClipMode.Bounds; layer1.AddChild(m_pInnerLayer, 1); // // Add two labels using BM label class // CCLabelBMFont CCLabelBMFont label1 = new CCLabelBMFont("LABEL1", "fonts/konqa32.fnt"); label1.Position = new CCPoint(m_pInnerLayer.ContentSize.Width, m_pInnerLayer.ContentSize.Height * 0.75f); m_pInnerLayer.AddChild(label1); CCLabelBMFont label2 = new CCLabelBMFont("LABEL2", "fonts/konqa32.fnt"); label2.Position = new CCPoint(0, m_pInnerLayer.ContentSize.Height * 0.25f); m_pInnerLayer.AddChild(label2); CCScaleTo scaleTo2 = new CCScaleTo(runTime * 0.25f, 3.0f); CCScaleTo scaleTo3 = new CCScaleTo(runTime * 0.25f, 1.0f); m_pInnerLayer.RepeatForever(scaleTo2, scaleTo3); CCFiniteTimeAction seq = new CCRepeatForever( new CCSequence(scaleTo2, scaleTo3) ); m_pInnerLayer.RunAction(seq); CCSize size = Layer.VisibleBoundsWorldspace.Size; var move1 = new CCMoveTo(2, new CCPoint(size.Width / 2, size.Height)); var move2 = new CCMoveTo(2, new CCPoint(size.Width, size.Height / 2)); var move3 = new CCMoveTo(2, new CCPoint(size.Width / 2, 0)); var move4 = new CCMoveTo(2, new CCPoint(0, size.Height / 2)); layer1.RunAction(new CCRepeatForever(new CCSequence(move1, move2, move3, move4))); }
public override void OnEnter() { base.OnEnter(); var s = Layer.VisibleBoundsWorldspace.Size; var layer1 = new CCLayerColor(new CCColor4B(192, 0, 0, 255)); layer1.IsColorCascaded = false; layer1.Position = new CCPoint(0, s.Height / 2); var sister1 = new CCSprite("Images/grossinis_sister1.png"); var sister2 = new CCSprite("Images/grossinis_sister2.png"); var label = new CCLabelBMFont("Test", "fonts/bitmapFontTest.fnt"); layer1.AddChild(sister1); layer1.AddChild(sister2); layer1.AddChild(label); this.AddChild(layer1, 0, kTagLayer); sister1.Position = new CCPoint(s.Width * 1 / 3, 0); sister2.Position = new CCPoint(s.Width * 2 / 3, 0); label.Position = new CCPoint(s.Width / 2, 0); // Define our delay time var delay = new CCDelayTime (1); layer1.RepeatForever ( new CCTintTo(6, 255, 0, 255), new CCTintTo(6, 255, 255, 255), delay ); sister1.RepeatForever ( new CCTintTo(2, 255, 255, 0), new CCTintTo(2, 255, 255, 255), new CCTintTo(2, 0, 255, 255), new CCTintTo(2, 255, 255, 255), new CCTintTo(2, 255, 0, 255), new CCTintTo(2, 255, 255, 255), delay ); }
public MenuLayer1() { // Register Touch Event touchListener = new CCEventListenerTouchOneByOne(); touchListener.IsSwallowTouches = true; touchListener.OnTouchBegan = onTouchBegan; touchListener.OnTouchMoved = onTouchMoved; touchListener.OnTouchEnded = onTouchEnded; touchListener.OnTouchCancelled = onTouchCancelled; AddEventListener(touchListener, 1); // We do not have an HD version of the menuitemsprite so internally CocosSharp tries to convert our // rectangle coordinates passed to work with HD images so the coordinates are off. We will just // modify this here to make sure we have the correct sizes when they are passed. CCSprite spriteNormal = new CCSprite(s_MenuItem, new CCRect(0, 23 * 2, 115, 23)); CCSprite spriteSelected = new CCSprite(s_MenuItem, new CCRect(0, 23 * 1, 115, 23)); CCSprite spriteDisabled = new CCSprite(s_MenuItem, new CCRect(0, 23 * 0, 115, 23)); var item1 = new CCMenuItemImage(spriteNormal, spriteSelected, spriteDisabled, this.menuCallback); // Image Item var item2 = new CCMenuItemImage(s_SendScore, s_PressSendScore, this.menuCallback2); // Label Item (LabelAtlas) var labelAtlas = new CCLabelAtlas("0123456789", "Images/fps_Images.png", 12, 32, '.'); var item3 = new CCMenuItemLabelAtlas(labelAtlas, this.menuCallbackDisabled); item3.DisabledColor = new CCColor3B(32, 32, 64); item3.Color = new CCColor3B(200, 200, 255); // Font Item CCMenuItemFont item4 = new CCMenuItemFont("I toggle enable items", (sender) => { disabledItem.Enabled = !disabledItem.Enabled; }); // Label Item (CCLabelBMFont) CCLabelBMFont label = new CCLabelBMFont("configuration", "fonts/bitmapFontTest3.fnt"); CCMenuItemLabelBMFont item5 = new CCMenuItemLabelBMFont(label, this.menuCallbackConfig); // Testing issue #500 item5.Scale = 0.8f; CCMenuItemFont.FontSize = 30; // Events CCMenuItemFont item6 = new CCMenuItemFont("Priority Test", menuCallbackPriorityTest); // Font Item CCMenuItemFont item7 = new CCMenuItemFont("Quit", this.onQuit); item7.RepeatForever(color_action, color_action.Reverse()); menu = new CCMenu(item1, item2, item3, item4, item5, item6, item7); menu.AlignItemsVertically(); disabledItem = item3; disabledItem.Enabled = false; AddChild(menu); menu.Scale = 0; menu.RunAction(new CCScaleTo(1, 1)); }
public CCMenuItemLabelBMFont(CCLabelBMFont labelBMFont, Action <object> target = null) : base(target) { LabelBMFont = labelBMFont; }
public void PurgeAllCachedData() { CCLabelBMFont.PurgeCachedData(); }
public LabelBMFontHD() { // CCLabelBMFont label1 = new CCLabelBMFont("TESTING RETINA DISPLAY", "fonts/konqa32.fnt"); AddChild(label1); }
protected override void AddedToScene() { base.AddedToScene(); // ask director the the window size var size = Layer.VisibleBoundsWorldspace.Size; // create and initialize a Label label = new CCLabelBMFont(LongSentencesExample, "fonts/markerFelt.fnt", size.Width / 1.5f, CCTextAlignment.Center); arrowsBar = new CCSprite("Images/arrowsBar"); arrows = new CCSprite("Images/arrows"); CCMenuItemFont.FontSize = 20; CCMenuItemFont.FontName = "arial"; var longSentences = new CCMenuItemFont("Long Flowing Sentences", stringChanged); var lineBreaks = new CCMenuItemFont("Short Sentences With Intentional Line Breaks", stringChanged); var mixed = new CCMenuItemFont("Long Sentences Mixed With Intentional Line Breaks", stringChanged); var stringMenu = new CCMenu(longSentences, lineBreaks, mixed); stringMenu.AlignItemsVertically(); longSentences.Color = CCColor3B.Red; lastSentenceItem = longSentences; longSentences.Tag = LongSentences; lineBreaks.Tag = LineBreaks; mixed.Tag = Mixed; CCMenuItemFont.FontSize = 30; var left = new CCMenuItemFont("Left", alignmentChanged); var center = new CCMenuItemFont("Center", alignmentChanged); var right = new CCMenuItemFont("Right", alignmentChanged); var alignmentMenu = new CCMenu(left, center, right); alignmentMenu.AlignItemsHorizontally(alignmentItemPadding); center.Color = CCColor3B.Red; m_pLastAlignmentItem = center; left.Tag = LeftAlign; center.Tag = CenterAlign; right.Tag = RightAlign; // position the label on the center of the screen label.Position = size.Center; arrowsBar.Visible = false; float arrowsWidth = (ArrowsMax - ArrowsMin) * size.Width; arrowsBar.ScaleX = (arrowsWidth / arrowsBar.ContentSize.Width); arrowsBar.Position = new CCPoint(((ArrowsMax + ArrowsMin) / 2) * size.Width, label.Position.Y); snapArrowsToEdge(); stringMenu.Position = new CCPoint(size.Width / 2, size.Height - menuItemPaddingCenter); alignmentMenu.Position = new CCPoint(size.Width / 2, menuItemPaddingCenter + 15); AddChild(label); AddChild(arrowsBar); AddChild(arrows); AddChild(stringMenu); AddChild(alignmentMenu); }
public MenuLayer4() { CCMenuItemFont.FontSize = 18; CCMenuItemFont.FontName = "arial"; CCMenuItemFont title1 = new CCMenuItemFont("Sound"); title1.Enabled = false; CCMenuItemFont.FontSize = 34; CCMenuItemToggle item1 = new CCMenuItemToggle(this.menuCallback, new CCMenuItemFont("On"), new CCMenuItemFont("Off")); CCMenuItemFont.FontSize = 18; CCMenuItemFont title2 = new CCMenuItemFont("Music"); title2.Enabled = false; CCMenuItemFont.FontSize = 34; CCMenuItemToggle item2 = new CCMenuItemToggle(this.menuCallback, new CCMenuItemFont("On"), new CCMenuItemFont("Off")); CCMenuItemFont.FontSize = 18; CCMenuItemFont title3 = new CCMenuItemFont("Quality"); title3.Enabled = false; CCMenuItemFont.FontSize = 34; CCMenuItemToggle item3 = new CCMenuItemToggle(this.menuCallback, new CCMenuItemFont("High"), new CCMenuItemFont("Low")); CCMenuItemFont.FontSize = 18; CCMenuItemFont title4 = new CCMenuItemFont("Orientation"); title4.Enabled = false; CCMenuItemFont.FontSize = 34; CCMenuItemToggle item4 = new CCMenuItemToggle(this.menuCallback, new CCMenuItemFont("Off")); item4.AddToggleMenuItems(new CCMenuItemFont ("33%"), new CCMenuItemFont ("66%"), new CCMenuItemFont ("100%")); // you can change the one of the items by doing this item4.SelectedIndex = 2; CCLabelBMFont label = new CCLabelBMFont("go back", "fonts/bitmapFontTest3.fnt"); CCMenuItemLabelBMFont back = new CCMenuItemLabelBMFont(label, this.backCallback); CCMenu menu = new CCMenu( title1, title2, item1, item2, title3, title4, item3, item4, back) { Tag = 36 }; // 9 items. menu.AlignItemsInColumns(2, 2, 2, 2, 1); AddChild(menu); }
public LabelBMFontChinese() { pLable = new CCLabelBMFont("中国", "fonts/bitmapFontChinese.fnt"); AddChild(pLable); }
protected override void AddedToScene() { base.AddedToScene(); // We do not have an HD version of the menuitemsprite so internally CocosSharp tries to convert our // rectangle coordinates passed to work with HD images so the coordinates are off. We will just // modify this here to make sure we have the correct sizes when they are passed. CCSprite spriteNormal = new CCSprite(s_MenuItem, new CCRect(0, 23 * 2, 115, 23)); CCSprite spriteSelected = new CCSprite(s_MenuItem, new CCRect(0, 23 * 1, 115, 23)); CCSprite spriteDisabled = new CCSprite(s_MenuItem, new CCRect(0, 23 * 0, 115, 23)); var item1 = new CCMenuItemImage(spriteNormal, spriteSelected, spriteDisabled, this.menuCallback); // Image Item var item2 = new CCMenuItemImage(s_SendScore, s_PressSendScore, this.menuCallback2); // Label Item (LabelAtlas) var labelAtlas = new CCLabelAtlas("0123456789", "Images/fps_Images.png", 12, 32, '.'); var item3 = new CCMenuItemLabelAtlas(labelAtlas, this.menuCallbackDisabled); item3.DisabledColor = new CCColor3B(32, 32, 64); item3.Color = new CCColor3B(200, 200, 255); // Font Item CCMenuItemFont item4 = new CCMenuItemFont("I toggle enable items", (sender) => { disabledItem.Enabled = !disabledItem.Enabled; }); // Label Item (CCLabelBMFont) CCLabelBMFont label = new CCLabelBMFont("configuration", "fonts/bitmapFontTest3.fnt"); CCMenuItemLabelBMFont item5 = new CCMenuItemLabelBMFont(label, this.menuCallbackConfig); // Testing issue #500 item5.Scale = 0.8f; CCMenuItemFont.FontSize = 30; // Events CCMenuItemFont item6 = new CCMenuItemFont("Priority Test", menuCallbackPriorityTest); // Font Item CCMenuItemFont item7 = new CCMenuItemFont("Quit", this.onQuit); item7.RepeatForever(color_action, color_action.Reverse()); menu = new CCMenu(item1, item2, item3, item4, item5, item6, item7); menu.AlignItemsVertically(); disabledItem = item3; disabledItem.Enabled = false; AddChild(menu); menu.Scale = 0; menu.RunAction(new CCScaleTo(1, 1)); // elastic effect CCSize s = Layer.VisibleBoundsWorldspace.Size; int i = 0; CCNode child; var pArray = menu.Children; object pObject = null; if (pArray.Count > 0) { for (int j = 0; j < pArray.Count; j++) { pObject = pArray[j]; if (pObject == null) break; child = (CCNode) pObject; CCPoint dstPoint = child.Position; int offset = (int) (s.Width / 2 + 50); if (i % 2 == 0) offset = -offset; child.Position = new CCPoint(dstPoint.X + offset, dstPoint.Y); child.RunAction(new CCEaseElasticOut(new CCMoveBy(2, new CCPoint(dstPoint.X - offset, 0)), 0.35f)); i++; } } }
public CCMenuItemLabelBMFont(CCLabelBMFont labelBMFont, Action<object> target = null) : base(target) { LabelBMFont = labelBMFont; }