public LabelBMFontChinese() { CCSize size = CCDirector.SharedDirector.WinSize; var pLable = new CCLabelBMFont("中国", "fonts/bitmapFontChinese.fnt"); pLable.Position = new CCPoint(size.Width / 2, size.Height / 2); AddChild(pLable); }
public AtlasBitmapColor() { CCSize s = CCDirector.sharedDirector().getWinSize(); CCLabelBMFont label = null; label = CCLabelBMFont.labelWithString("Blue", "fonts/bitmapFontTest5.fnt"); label.Color = ccBLUE; addChild(label); label.position = new CCPoint(s.width / 2, s.height / 4); label.anchorPoint = new CCPoint(0.5f, 0.5f); label = CCLabelBMFont.labelWithString("Red", "fonts/bitmapFontTest5.fnt"); addChild(label); label.position = new CCPoint(s.width / 2, 2 * s.height / 4); label.anchorPoint = new CCPoint(0.5f, 0.5f); label.Color = ccRED; label = CCLabelBMFont.labelWithString("G", "fonts/bitmapFontTest5.fnt"); addChild(label); label.position = new CCPoint(s.width / 2, 3 * s.height / 4); label.anchorPoint = new CCPoint(0.5f, 0.5f); label.Color = ccGREEN; label.setString("Green"); }
public LabelsEmpty() { CCSize s = CCDirector.sharedDirector().getWinSize(); // CCLabelBMFont CCLabelBMFont label1 = CCLabelBMFont.labelWithString("", "fonts/bitmapFontTest3.fnt"); addChild(label1, 0, (int)TagSprite.kTagBitmapAtlas1); label1.position = new CCPoint(s.width / 2, s.height - 100); // CCLabelTTF CCLabelTTF label2 = CCLabelTTF.labelWithString("", "Arial", 24); addChild(label2, 0, (int)TagSprite.kTagBitmapAtlas2); label2.position = new CCPoint(s.width / 2, s.height / 2); // CCLabelAtlas CCLabelAtlas label3 = CCLabelAtlas.labelWithString("", "fonts/tuffy_bold_italic-charmap.png", 48, 64, ' '); addChild(label3, 0, (int)TagSprite.kTagBitmapAtlas3); label3.position = new CCPoint(s.width / 2, 0 + 100); base.schedule(updateStrings, 1.0f); setEmpty = false; }
public IntervalLayer() { m_time0 = m_time1 = m_time2 = m_time3 = m_time4 = 0.0f; CCSize s = CCDirector.SharedDirector.WinSize; // sun CCParticleSystem sun = CCParticleSun.Create(); 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 = CCLabelBMFont.Create("0", "fonts/bitmapFontTest4.fnt"); m_label1 = CCLabelBMFont.Create("0", "fonts/bitmapFontTest4.fnt"); m_label2 = CCLabelBMFont.Create("0", "fonts/bitmapFontTest4.fnt"); m_label3 = CCLabelBMFont.Create("0", "fonts/bitmapFontTest4.fnt"); m_label4 = CCLabelBMFont.Create("0", "fonts/bitmapFontTest4.fnt"); ScheduleUpdate(); 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 ( (CCActionInterval) (CCSequence.FromActions(jump, jump.Reverse()))) ); // pause button CCMenuItem item1 = CCMenuItemFont.Create("Pause", onPause); CCMenu menu = new CCMenu(item1); menu.Position = new CCPoint(s.Width / 2, s.Height - 50); AddChild(menu); }
public LabelBMFontHD() { CCSize s = CCDirector.SharedDirector.WinSize; // CCLabelBMFont CCLabelBMFont label1 = new CCLabelBMFont("TESTING RETINA DISPLAY", "fonts/konqa32.fnt"); AddChild(label1); label1.Position = new CCPoint(s.Width / 2, s.Height / 2); }
public Atlas4() { m_time = 0; // Upper Label CCLabelBMFont label = CCLabelBMFont.labelWithString("Bitmap Font Atlas", "fonts/bitmapFontTest.fnt"); addChild(label); CCSize s = CCDirector.sharedDirector().getWinSize(); label.position = new CCPoint(s.width / 2, s.height / 2); label.anchorPoint = new CCPoint(0.5f, 0.5f); CCSprite BChar = (CCSprite)label.getChildByTag(1); CCSprite FChar = (CCSprite)label.getChildByTag(7); CCSprite AChar = (CCSprite)label.getChildByTag(12); CCActionInterval rotate = CCRotateBy.actionWithDuration(2, 360); CCAction rot_4ever = CCRepeatForever.actionWithAction(rotate); CCActionInterval scale = CCScaleBy.actionWithDuration(2, 1.5f); //CCActionInterval scale_back = scale.reverse(); CCActionInterval scale_back = null; CCFiniteTimeAction scale_seq = CCSequence.actions(scale, scale_back, null); CCAction scale_4ever = CCRepeatForever.actionWithAction((CCActionInterval)scale_seq); CCActionInterval jump = CCJumpBy.actionWithDuration(0.5f, new CCPoint(), 60, 1); CCAction jump_4ever = CCRepeatForever.actionWithAction(jump); CCActionInterval fade_out = CCFadeOut.actionWithDuration(1); CCActionInterval fade_in = CCFadeIn.actionWithDuration(1); CCFiniteTimeAction seq = CCSequence.actions(fade_out, fade_in, null); CCAction fade_4ever = CCRepeatForever.actionWithAction((CCActionInterval)seq); BChar.runAction(rot_4ever); BChar.runAction(scale_4ever); FChar.runAction(jump_4ever); AChar.runAction(fade_4ever); // Bottom Label CCLabelBMFont label2 = CCLabelBMFont.labelWithString("00.0", "fonts/bitmapFontTest.fnt"); addChild(label2, 0, (int)TagSprite.kTagBitmapAtlas2); label2.position = new CCPoint(s.width / 2.0f, 80); CCSprite lastChar = (CCSprite)label2.getChildByTag(3); lastChar.runAction((CCAction)(rot_4ever.copy())); //schedule( schedule_selector(Atlas4::step), 0.1f); base.schedule(step, 0.1f); }
public IntervalLayer() { m_time0 = m_time1 = m_time2 = m_time3 = m_time4 = 0.0f; CCSize s = CCDirector.sharedDirector().getWinSize(); // sun //CCParticleSystem sun = CCParticleSun.node(); //sun.Texture = CCTextureCache.sharedTextureCache().addImage("Images/fire"); //sun.position = (new CCPoint(s.width - 32, s.height - 32)); ////sun.setTotalParticles(130); //sun.Life = (0.6f); //this.addChild(sun); // timers m_label0 = CCLabelBMFont.labelWithString("0", "fonts/fnt/bitmapFontTest4"); m_label1 = CCLabelBMFont.labelWithString("0", "fonts/fnt/bitmapFontTest4"); m_label2 = CCLabelBMFont.labelWithString("0", "fonts/fnt/bitmapFontTest4"); m_label3 = CCLabelBMFont.labelWithString("0", "fonts/fnt/bitmapFontTest4"); m_label4 = CCLabelBMFont.labelWithString("0", "fonts/fnt/bitmapFontTest4"); base.scheduleUpdate(); schedule(step1); schedule(step2, 0); schedule(step3, 1.0f); schedule(step4, 2.0f); 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 = CCSprite.spriteWithFile(s_pPathGrossini); sprite.position = new CCPoint(40, 50); CCJumpBy jump = CCJumpBy.actionWithDuration(3, new CCPoint(s.width - 80, 0), 50, 4); addChild(sprite); sprite.runAction(CCRepeatForever.actionWithAction( (CCActionInterval)(CCSequence.actions(jump, jump.reverse())) ) ); // pause button CCMenuItem item1 = CCMenuItemFont.itemFromString("Pause", this, onPause); CCMenu menu = CCMenu.menuWithItems(item1); menu.position = new CCPoint(s.width / 2, s.height - 50); addChild(menu); }
public LabelBMFontHD() { CCSize s = CCDirector.sharedDirector().getWinSize(); // CCLabelBMFont CCLabelBMFont label1 = CCLabelBMFont.labelWithString("TESTING RETINA DISPLAY", "fonts/konqa32.fnt"); addChild(label1); label1.position = new CCPoint(s.width / 2, s.height / 2); }
public static CCLabelBMFont labelWithString(string str, string fntFile) { CCLabelBMFont cCLabelBMFont = new CCLabelBMFont(); if (cCLabelBMFont.initWithString(str, fntFile)) { return(cCLabelBMFont); } return(null); }
public Atlas5() { CCLabelBMFont label = new CCLabelBMFont("abcdefg", "fonts/bitmapFontTest4.fnt"); AddChild(label); CCSize s = CCDirector.SharedDirector.WinSize; label.Position = new CCPoint(s.Width / 2, s.Height / 2); label.AnchorPoint = new CCPoint(0.5f, 0.5f); }
public BMFontInit() { CCSize s = CCDirector.SharedDirector.WinSize; var bmFont = new CCLabelBMFont(); //CCLabelBMFont* bmFont = [CCLabelBMFont create:@"Foo" fntFile:@"arial-unicode-26"]; bmFont.FntFile = "fonts/helvetica-32.fnt"; bmFont.Label = ("It is working!"); AddChild(bmFont); bmFont.Position = new CCPoint(s.Width / 2, s.Height / 4 * 2); }
public Atlas5() { CCLabelBMFont label = CCLabelBMFont.labelWithString("abcdefg", "fonts/bitmapFontTest4.fnt"); addChild(label); CCSize s = CCDirector.sharedDirector().getWinSize(); label.position = new CCPoint(s.width / 2, s.height / 2); label.anchorPoint = new CCPoint(0.5f, 0.5f); }
public LabelGlyphDesigner() { CCSize s = CCDirector.SharedDirector.WinSize; CCLayerColor layer = new CCLayerColor(new CCColor4B(128, 128, 128, 255)); AddChild(layer, -10); // CCLabelBMFont CCLabelBMFont label1 = new CCLabelBMFont("Testing Glyph Designer", "fonts/futura-48.fnt"); AddChild(label1); label1.Position = new CCPoint(s.Width / 2, s.Height / 2); }
public Issue1343() { CCSize s = CCDirector.SharedDirector.WinSize; var bmFont = new CCLabelBMFont(); bmFont.Init(); bmFont.FntFile = "fonts/font-issue1343.fnt"; bmFont.Label = ("ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890abcdefghijklmnopqrstuvwxyz.,'"); AddChild(bmFont); bmFont.Scale = 0.3f; bmFont.Position = new CCPoint(s.Width / 2, s.Height / 4 * 2); }
public BMFontOneAtlas() { CCSize s = CCDirector.SharedDirector.WinSize; CCLabelBMFont label1 = new CCLabelBMFont("This is Helvetica", "fonts/helvetica-32.fnt", CCLabelBMFont.kCCLabelAutomaticWidth, CCTextAlignment.CCTextAlignmentLeft, CCPoint.Zero); AddChild(label1); label1.Position = new CCPoint(s.Width / 2, s.Height / 3 * 2); CCLabelBMFont label2 = new CCLabelBMFont("And this is Geneva", "fonts/geneva-32.fnt", CCLabelBMFont.kCCLabelAutomaticWidth, CCTextAlignment.CCTextAlignmentLeft, new CCPoint(0, 128)); AddChild(label2); label2.Position = new CCPoint(s.Width / 2, s.Height / 3 * 1); }
public Atlas4() { m_time = 0; // Upper Label CCLabelBMFont label = new CCLabelBMFont("Bitmap Font Atlas", "fonts/bitmapFontTest.fnt"); AddChild(label); CCSize s = CCDirector.SharedDirector.WinSize; label.Position = new CCPoint(s.Width / 2, s.Height / 2); label.AnchorPoint = new CCPoint(0.5f, 0.5f); CCSprite BChar = (CCSprite)label.GetChildByTag(0); CCSprite FChar = (CCSprite)label.GetChildByTag(7); CCSprite AChar = (CCSprite)label.GetChildByTag(12); CCActionInterval rotate = new CCRotateBy (2, 360); CCAction rot_4ever = new CCRepeatForever (rotate); CCActionInterval scale = new CCScaleBy(2, 1.5f); CCFiniteTimeAction scale_back = scale.Reverse(); CCFiniteTimeAction scale_seq = CCSequence.FromActions(scale, scale_back); CCAction scale_4ever = new CCRepeatForever ((CCActionInterval)scale_seq); CCActionInterval jump = new CCJumpBy (0.5f, new CCPoint(), 60, 1); CCAction jump_4ever = new CCRepeatForever (jump); CCActionInterval fade_out = new CCFadeOut (1); CCActionInterval fade_in = new CCFadeIn (1); CCFiniteTimeAction seq = CCSequence.FromActions(fade_out, fade_in); CCAction fade_4ever = new CCRepeatForever ((CCActionInterval)seq); BChar.RunAction(rot_4ever); BChar.RunAction(scale_4ever); FChar.RunAction(jump_4ever); AChar.RunAction(fade_4ever); // Bottom Label CCLabelBMFont label2 = new CCLabelBMFont("00.0", "fonts/bitmapFontTest.fnt"); AddChild(label2, 0, (int)TagSprite.kTagBitmapAtlas2); label2.Position = new CCPoint(s.Width / 2.0f, 80); CCSprite lastChar = (CCSprite)label2.GetChildByTag(3); lastChar.RunAction((CCAction)(rot_4ever.Copy())); //schedule( schedule_selector(Atlas4::step), 0.1f); base.Schedule(step, 0.1f); }
public virtual void step(float dt) { m_time += dt; //char string[10] = {0}; string Stepstring; //sprintf(string, "%04.1f", m_time); Stepstring = string.Format("{0,4:1f}", m_time); // std::string string; // string.format("%04.1f", m_time); CCLabelBMFont label1 = (CCLabelBMFont)getChildByTag((int)TagSprite.kTagBitmapAtlas2); label1.setString(Stepstring); }
public bool initWithString(string theString, string fntFile) { this.m_pConfiguration = CCLabelBMFont.FNTConfigLoadFile(fntFile); if (!base.initWithFile(this.m_pConfiguration.m_sAtlasName, theString.Length)) { return(false); } this.m_cOpacity = 255; this.m_tColor = new ccColor3B(255, 255, 255); this.m_tContentSize = new CCSize(0f, 0f); this.m_bIsOpacityModifyRGB = this.m_pobTextureAtlas.Texture.HasPremultipliedAlpha; this.anchorPoint = new CCPoint(0.5f, 0.5f); this.setString(theString); return(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,d}-", i); CCLabelBMFont label = CCLabelBMFont.labelWithString(str, "fonts/bitmapFontTest.fnt"); addChild(label); CCSize s = CCDirector.sharedDirector().getWinSize(); CCPoint p = new CCPoint(ccMacros.CCRANDOM_0_1() * s.width, ccMacros.CCRANDOM_0_1() * s.height); label.position = p; label.anchorPoint = new CCPoint(0.5f, 0.5f); } }
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); CCLabelBMFont label = new CCLabelBMFont(str, "fonts/bitmapFontTest.fnt"); AddChild(label); CCSize s = CCDirector.SharedDirector.WinSize; CCPoint p = new CCPoint(CCMacros.CCRandomBetween0And1() * s.Width, CCMacros.CCRandomBetween0And1() * s.Height); label.Position = p; label.AnchorPoint = new CCPoint(0.5f, 0.5f); } }
public override void onEnter() { base.onEnter(); CCSize s = CCDirector.sharedDirector().getWinSize(); // add title CCLabelTTF label = CCLabelTTF.labelWithString(title(), "Arial", 32); addChild(label, 1); label.position = new CCPoint(s.width / 2, s.height - 50); CCNode ccnode = new CCNode(); ccnode.sheduleUpdate(); m_plabel = CCLabelBMFont.labelWithString("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 override void OnEnter() { base.OnEnter(); CCSize s = CCDirector.SharedDirector.WinSize; // add title CCLabelTTF label = new CCLabelTTF(title(), "arial", 32); AddChild(label, 1); label.Position = new CCPoint(s.Width / 2, s.Height - 50); CCNode ccnode = new CCNode(); ccnode.ScheduleUpdate(); 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 Atlas6() { CCSize s = CCDirector.SharedDirector.WinSize; CCLabelBMFont label = null; label = new CCLabelBMFont("FaFeFiFoFu", "fonts/bitmapFontTest5.fnt"); AddChild(label); label.Position = new CCPoint(s.Width / 2, s.Height / 2 + 50); label.AnchorPoint = new CCPoint(0.5f, 0.5f); label = new CCLabelBMFont("fafefifofu", "fonts/bitmapFontTest5.fnt"); AddChild(label); label.Position = new CCPoint(s.Width / 2, s.Height / 2); label.AnchorPoint = new CCPoint(0.5f, 0.5f); label = new CCLabelBMFont("aeiou", "fonts/bitmapFontTest5.fnt"); AddChild(label); label.Position = new CCPoint(s.Width / 2, s.Height / 2 - 50); label.AnchorPoint = new CCPoint(0.5f, 0.5f); }
public Atlas3() { m_time = 0; CCLayerColor col = new CCLayerColor(new CCColor4B(128, 128, 128, 255)); AddChild(col, -10); CCLabelBMFont label1 = new CCLabelBMFont("Test", "fonts/bitmapFontTest2.fnt"); // testing anchors label1.AnchorPoint = new CCPoint(0, 0); AddChild(label1, 0, (int)TagSprite.kTagBitmapAtlas1); CCActionInterval fade = new CCFadeOut (1.0f); CCFiniteTimeAction fade_in = fade.Reverse(); CCFiniteTimeAction seq = CCSequence.FromActions(fade, fade_in); CCAction repeat = new CCRepeatForever ((CCActionInterval)seq); label1.RunAction(repeat); // 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 CCLabelBMFont label2 = new CCLabelBMFont("Test", "fonts/bitmapFontTest2.fnt"); // testing anchors label2.AnchorPoint = new CCPoint(0.5f, 0.5f); label2.Color = ccRED; AddChild(label2, 0, (int)TagSprite.kTagBitmapAtlas2); label2.RunAction((CCAction)(repeat.Copy())); CCLabelBMFont label3 = new CCLabelBMFont("Test", "fonts/bitmapFontTest2.fnt"); // testing anchors label3.AnchorPoint = new CCPoint(1, 1); AddChild(label3, 0, (int)TagSprite.kTagBitmapAtlas3); CCSize s = CCDirector.SharedDirector.WinSize; label1.Position = new CCPoint(); label2.Position = new CCPoint(s.Width / 2, s.Height / 2); label3.Position = new CCPoint(s.Width, s.Height); base.Schedule(step);//:@selector(step:)]; }
public Atlas6() { CCSize s = CCDirector.sharedDirector().getWinSize(); CCLabelBMFont label = null; label = CCLabelBMFont.labelWithString("FaFeFiFoFu", "fonts/bitmapFontTest5.fnt"); addChild(label); label.position = new CCPoint(s.width / 2, s.height / 2 + 50); label.anchorPoint = new CCPoint(0.5f, 0.5f); label = CCLabelBMFont.labelWithString("fafefifofu", "fonts/bitmapFontTest5.fnt"); addChild(label); label.position = new CCPoint(s.width / 2, s.height / 2); label.anchorPoint = new CCPoint(0.5f, 0.5f); label = CCLabelBMFont.labelWithString("aeiou", "fonts/bitmapFontTest5.fnt"); addChild(label); label.position = new CCPoint(s.width / 2, s.height / 2 - 50); label.anchorPoint = new CCPoint(0.5f, 0.5f); }
public BitmapFontMultiLine() { CCSize s; // Left CCLabelBMFont label1 = CCLabelBMFont.labelWithString("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 CCLabelBMFont label2 = CCLabelBMFont.labelWithString("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 CCLabelBMFont label3 = CCLabelBMFont.labelWithString("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); s = CCDirector.sharedDirector().getWinSize(); label1.position = new CCPoint(); label2.position = new CCPoint(s.width / 2, s.height / 2); label3.position = new CCPoint(s.width, s.height); }
public MenuLayer3() { CCMenuItemFont.FontName = "arial"; CCMenuItemFont.FontSize = 28; CCLabelBMFont label = new CCLabelBMFont("Enable AtlasItem", "fonts/bitmapFontTest3.fnt"); CCMenuItemLabel item1 = new CCMenuItemLabel(label, this.menuCallback2); CCMenuItemFont item2 = new CCMenuItemFont("--- Go Back ---", this.menuCallback); 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)); CCMenuItemSprite item3 = new CCMenuItemSprite(spriteNormal, spriteSelected, spriteDisabled, this.menuCallback3); m_disabledItem = item3; m_disabledItem.Enabled = false; CCMenu menu = new CCMenu(item1, item2, item3); menu.Position = new CCPoint(0, 0); CCSize s = CCDirector.SharedDirector.WinSize; 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); CCJumpBy jump = new CCJumpBy (3, new CCPoint(400, 0), 50, 4); item2.RunAction(new CCRepeatForever ( (CCActionInterval)(CCSequence.FromActions(jump, jump.Reverse())) ) ); CCActionInterval spin1 = new CCRotateBy (3, 360); CCActionInterval spin2 = (CCActionInterval)(spin1.Copy()); CCActionInterval spin3 = (CCActionInterval)(spin1.Copy()); item1.RunAction(new CCRepeatForever (spin1)); item2.RunAction(new CCRepeatForever (spin2)); item3.RunAction(new CCRepeatForever (spin3)); AddChild(menu); }
public override void OnEnter() { base.OnEnter(); this.TouchEnabled = true; CCSize s = CCDirector.SharedDirector.WinSize; CCLayerColor layer = new CCLayerColor(new CCColor4B(0xFF, 0x00, 0x00, 0x80), s.Width * 0.75f, s.Height * 0.75f); 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 CCLabelBMFont label1 = new CCLabelBMFont("LABEL1", "fonts/konqa32.fnt"); layer.AddChild(label1); label1.Position = new CCPoint(layer.ContentSize.Width / 2, layer.ContentSize.Height * 0.75f); CCLabelBMFont 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 float waitTime = 3f; float runTime = 12f; layer.Visible = false; CCHide hide = new CCHide(); CCScaleTo scaleTo1 = new CCScaleTo(0.0f, 0.0f); CCShow show = new CCShow(); CCDelayTime delay = new CCDelayTime (waitTime); CCScaleTo scaleTo2 = new CCScaleTo(runTime * 0.25f, 1.2f); CCScaleTo scaleTo3 = new CCScaleTo(runTime * 0.25f, 0.95f); CCScaleTo scaleTo4 = new CCScaleTo(runTime * 0.25f, 1.1f); CCScaleTo scaleTo5 = new CCScaleTo(runTime * 0.25f, 1.0f); CCFiniteTimeAction seq = CCSequence.FromActions(hide, scaleTo1, show, delay, scaleTo2, scaleTo3, scaleTo4, scaleTo5); layer.RunAction(seq); }
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.setString("not empty"); label2.setString("not empty"); label3.setString("hi"); setEmpty = true; } else { label1.setString(""); label2.setString(""); label3.setString(""); setEmpty = false; } }
public LabelsEmpty() { CCSize s = CCDirector.SharedDirector.WinSize; // CCLabelBMFont CCLabelBMFont label1 = new CCLabelBMFont("", "fonts/bitmapFontTest3.fnt"); AddChild(label1, 0, (int)TagSprite.kTagBitmapAtlas1); label1.Position = new CCPoint(s.Width / 2, s.Height - 100); // CCLabelTTF CCLabelTTF label2 = new CCLabelTTF("", "arial", 24); AddChild(label2, 0, (int)TagSprite.kTagBitmapAtlas2); label2.Position = new CCPoint(s.Width / 2, s.Height / 2); // CCLabelAtlas CCLabelAtlas label3 = new CCLabelAtlas("", "fonts/tuffy_bold_italic-charmap", 48, 64, ' '); AddChild(label3, 0, (int)TagSprite.kTagBitmapAtlas3); label3.Position = new CCPoint(s.Width / 2, 0 + 100); base.Schedule(updateStrings, 1.0f); setEmpty = false; }
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; CCSize s = CCDirector.SharedDirector.WinSize; CCLabelBMFont label1 = new CCLabelBMFont(spanish, "fonts/arial-unicode-26.fnt", 200, CCTextAlignment.CCTextAlignmentLeft); AddChild(label1); label1.Position = new CCPoint(s.Width / 2, s.Height / 4 * 3); CCLabelBMFont label2 = new CCLabelBMFont(chinese, "fonts/arial-unicode-26.fnt"); AddChild(label2); label2.Position = new CCPoint(s.Width / 2, s.Height / 4 * 2); CCLabelBMFont label3 = new CCLabelBMFont(japanese, "fonts/arial-unicode-26.fnt"); AddChild(label3); label3.Position = new CCPoint(s.Width / 2, s.Height / 4 * 1); }
public BitmapFontMultiLine() { CCSize s; // Left CCLabelBMFont 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 CCLabelBMFont 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 CCLabelBMFont 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); s = CCDirector.SharedDirector.WinSize; label1.Position = new CCPoint(); label2.Position = new CCPoint(s.Width / 2, s.Height / 2); label3.Position = new CCPoint(s.Width, s.Height); }
public AtlasBitmapColor() { CCSize s = CCDirector.SharedDirector.WinSize; CCLabelBMFont label = null; label = new CCLabelBMFont("Blue", "fonts/bitmapFontTest5.fnt"); label.Color = ccBLUE; AddChild(label); label.Position = new CCPoint(s.Width / 2, s.Height / 4); label.AnchorPoint = new CCPoint(0.5f, 0.5f); label = new CCLabelBMFont("Red", "fonts/bitmapFontTest5.fnt"); AddChild(label); label.Position = new CCPoint(s.Width / 2, 2 * s.Height / 4); label.AnchorPoint = new CCPoint(0.5f, 0.5f); label.Color = ccRED; label = new CCLabelBMFont("G", "fonts/bitmapFontTest5.fnt"); AddChild(label); label.Position = new CCPoint(s.Width / 2, 3 * s.Height / 4); label.AnchorPoint = new CCPoint(0.5f, 0.5f); label.Color = ccGREEN; label.Label = ("Green"); }
public static new CCLabelBMFont Create() { var pRet = new CCLabelBMFont(); pRet.Init(); return pRet; }
public static void purgeCachedData() { CCLabelBMFont.FNTConfigRemoveCache(); }
public MenuLayer4() { CCMenuItemFont.FontName = "arial"; CCMenuItemFont.FontSize = 18; CCMenuItemFont title1 = new CCMenuItemFont("Sound"); title1.Enabled = false; CCMenuItemFont.FontName = "arial"; CCMenuItemFont.FontSize = 34; CCMenuItemToggle item1 = new CCMenuItemToggle(this.menuCallback, new CCMenuItemFont("On"), new CCMenuItemFont("Off")); CCMenuItemFont.FontName = "arial"; CCMenuItemFont.FontSize = 18; CCMenuItemFont title2 = new CCMenuItemFont("Music"); title2.Enabled = false; CCMenuItemFont.FontName = "arial"; CCMenuItemFont.FontSize = 34; CCMenuItemToggle item2 = new CCMenuItemToggle(this.menuCallback, new CCMenuItemFont("On"), new CCMenuItemFont("Off")); CCMenuItemFont.FontName = "arial"; CCMenuItemFont.FontSize = 18; CCMenuItemFont title3 = new CCMenuItemFont("Quality"); title3.Enabled = false; CCMenuItemFont.FontName = "arial"; CCMenuItemFont.FontSize = 34; CCMenuItemToggle item3 = new CCMenuItemToggle(this.menuCallback, new CCMenuItemFont("High"), new CCMenuItemFont("Low")); CCMenuItemFont.FontName = "arial"; CCMenuItemFont.FontSize = 18; CCMenuItemFont title4 = new CCMenuItemFont("Orientation"); title4.Enabled = false; CCMenuItemFont.FontName = "arial"; CCMenuItemFont.FontSize = 34; CCMenuItemToggle item4 = new CCMenuItemToggle(this.menuCallback, new CCMenuItemFont("Off")); item4.SubItems.Add(new CCMenuItemFont("33%")); item4.SubItems.Add(new CCMenuItemFont("66%")); item4.SubItems.Add(new CCMenuItemFont("100%")); // you can change the one of the items by doing this item4.SelectedIndex = 2; CCMenuItemFont.FontName = "arial"; CCMenuItemFont.FontSize = 34; CCLabelBMFont label = new CCLabelBMFont("go back", "fonts/bitmapFontTest3.fnt"); CCMenuItemLabel back = new CCMenuItemLabel(label, this.backCallback); CCMenu menu = new CCMenu( title1, title2, item1, item2, title3, title4, item3, item4, back); // 9 items. menu.AlignItemsInColumns(2, 2, 2, 2, 1); AddChild(menu); }
public MenuLayer1() { CCMenuItemFont.FontSize = 30; CCMenuItemFont.FontName = "arial"; base.TouchEnabled = true; // Font Item 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)); CCMenuItemSprite item1 = new CCMenuItemSprite(spriteNormal, spriteSelected, spriteDisabled, this.menuCallback); // Image Item CCMenuItem item2 = new CCMenuItemImage(s_SendScore, s_PressSendScore, this.menuCallback2); // Label Item (LabelAtlas) CCLabelAtlas labelAtlas = new CCLabelAtlas("0123456789", "Images/fps_Images", 16, 24, '.'); CCMenuItemLabel item3 = new CCMenuItemLabel(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", this.menuCallbackEnable); item4.FontSizeObj = 20; item4.FontNameObj = "arial"; // Label Item (CCLabelBMFont) CCLabelBMFont label = new CCLabelBMFont("configuration", "fonts/bitmapFontTest3.fnt"); CCMenuItemLabel item5 = new CCMenuItemLabel(label, this.menuCallbackConfig); // Testing issue #500 item5.Scale = 0.8f; // Events CCMenuItemFont.FontName = "arial"; CCMenuItemFont item6 = new CCMenuItemFont("Priority Test", menuCallbackPriorityTest); // Font Item CCMenuItemFont item7 = new CCMenuItemFont("Quit", this.onQuit); CCActionInterval color_action = new CCTintBy (0.5f, 0, -255, -255); CCActionInterval color_back = (CCActionInterval)color_action.Reverse(); CCFiniteTimeAction seq = CCSequence.FromActions(color_action, color_back); item7.RunAction(new CCRepeatForever ((CCActionInterval)seq)); CCMenu menu = new CCMenu(item1, item2, item3, item4, item5, item6, item7); menu.AlignItemsVertically(); // elastic effect CCSize s = CCDirector.SharedDirector.WinSize; 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++; } } m_disabledItem = item3; m_disabledItem.Enabled = false; AddChild(menu); }
/// <summary> /// creates a bitmap font altas with an initial string and the FNT file /// </summary> public static CCLabelBMFont labelWithString(string str, string fntFile) { CCLabelBMFont pRet = new CCLabelBMFont(); if (pRet.initWithString(str, fntFile)) { return pRet; } return null; }
public BitmapFontMultiLineAlignment() { TouchEnabled = true; // ask director the the window size CCSize size = CCDirector.SharedDirector.WinSize; // create and initialize a Label m_pLabelShouldRetain = CCLabelBMFont.Create(LongSentencesExample, "fonts/markerFelt.fnt", size.Width / 1.5f, CCTextAlignment.CCTextAlignmentCenter); m_pArrowsBarShouldRetain = new CCSprite("Images/arrowsBar"); m_pArrowsShouldRetain = new CCSprite("Images/arrows"); CCMenuItemFont.FontSize = 20; CCMenuItemFont longSentences = CCMenuItemFont.Create("Long Flowing Sentences", stringChanged); CCMenuItemFont lineBreaks = CCMenuItemFont.Create("Short Sentences With Intentional Line Breaks", stringChanged); CCMenuItemFont mixed = CCMenuItemFont.Create("Long Sentences Mixed With Intentional Line Breaks", stringChanged); CCMenu stringMenu = new CCMenu(longSentences, lineBreaks, mixed); stringMenu.AlignItemsVertically(); longSentences.Color = CCTypes.CCRed; m_pLastSentenceItem = longSentences; longSentences.Tag = LongSentences; lineBreaks.Tag = LineBreaks; mixed.Tag = Mixed; CCMenuItemFont.FontSize = 30; CCMenuItemFont left = CCMenuItemFont.Create("Left", alignmentChanged); CCMenuItemFont center = CCMenuItemFont.Create("Center", alignmentChanged); CCMenuItemFont right = CCMenuItemFont.Create("Right", alignmentChanged); CCMenu alignmentMenu = new CCMenu(left, center, right); alignmentMenu.AlignItemsHorizontallyWithPadding(alignmentItemPadding); center.Color = CCTypes.CCRed; m_pLastAlignmentItem = center; left.Tag = (LeftAlign); center.Tag = (CenterAlign); right.Tag = (RightAlign); // position the label on the center of the screen m_pLabelShouldRetain.Position = new CCPoint(size.Width / 2, size.Height / 2); m_pArrowsBarShouldRetain.Visible = (false); float arrowsWidth = (ArrowsMax - ArrowsMin) * size.Width; m_pArrowsBarShouldRetain.ScaleX = (arrowsWidth / m_pArrowsBarShouldRetain.ContentSize.Width); m_pArrowsBarShouldRetain.Position = new CCPoint(((ArrowsMax + ArrowsMin) / 2) * size.Width, m_pLabelShouldRetain.Position.Y); snapArrowsToEdge(); stringMenu.Position = new CCPoint(size.Width / 2, size.Height - menuItemPaddingCenter); alignmentMenu.Position = new CCPoint(size.Width / 2, menuItemPaddingCenter + 15); AddChild(m_pLabelShouldRetain); AddChild(m_pArrowsBarShouldRetain); AddChild(m_pArrowsShouldRetain); AddChild(stringMenu); AddChild(alignmentMenu); }
public static CCLabelBMFont Create(string str, string fntFile, float width, CCTextAlignment alignment, CCPoint imageOffset) { var pRet = new CCLabelBMFont(); pRet.InitWithString(str, fntFile, width, alignment, imageOffset); return pRet; }