public LabelAtlasHD() { // CCLabelBMFont label1 = new CCLabelAtlas("TESTING RETINA DISPLAY", "fonts/larabie-16", 10, 20, 'A'); label1.AnchorPoint = CCPoint.AnchorMiddle; AddChild(label1); }
public LabelAtlasTest() { m_time = 0; var label1 = new CCLabelAtlas("123 Test", "fonts/tuffy_bold_italic-charmap", 48, 64, ' '); AddChild(label1, 0, (int)TagSprite.kTagSprite1); label1.Position = new CCPoint(10, 100); label1.Opacity = 200; var label2 = new CCLabelAtlas("0123456789", "fonts/tuffy_bold_italic-charmap", 48, 64, ' '); AddChild(label2, 0, (int)TagSprite.kTagSprite2); label2.Position = new CCPoint(10, 200); label2.Opacity = 32; Schedule(step); }
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; }
public LabelAtlasColorTest() { CCLabelAtlas label1 = new CCLabelAtlas("123 Test", "fonts/tuffy_bold_italic-charmap", 48, 64, ' '); AddChild(label1, 0, (int)TagSprite.kTagSprite1); label1.Position = new CCPoint(10, 100); label1.Opacity = 200; CCLabelAtlas label2 = new CCLabelAtlas("0123456789", "fonts/tuffy_bold_italic-charmap", 48, 64, ' '); AddChild(label2, 0, (int)TagSprite.kTagSprite2); label2.Position = new CCPoint(10, 200); label2.Color = ccRED; CCFiniteTimeAction fade = new CCFadeOut (1.0f); CCFiniteTimeAction fade_in = fade.Reverse(); CCFiniteTimeAction seq = new CCSequence(fade, fade_in); CCAction repeat = new CCRepeatForever ((CCFiniteTimeAction)seq); label2.RunAction(repeat); m_time = 0; Schedule(step); //:@selector(step:)]; }
public CCMenuItemLabelAtlas(CCLabelAtlas labelAtlas, Action <object> target = null) : base(target) { LabelAtlas = labelAtlas; }
public ParticleDemo() { toggleParticleMovMenuItem = new CCMenuItemToggle(ToggleCallback, new CCMenuItemFont("Free Movement"), new CCMenuItemFont("Relative Movement"), new CCMenuItemFont("Grouped Movement")); particleMenu = new CCMenu(toggleParticleMovMenuItem); AddChild(particleMenu, 100); particleCounter = new CCLabelAtlas("0000", "Images/fps_Images", 16, 64, '.'); AddChild(particleCounter, 100, ParticleTestScene.TagLabelAtlas); Background = new CCSprite(TestResource.s_back3); AddChild(Background, 5); // Add event listeners var listener = new CCEventListenerTouchAllAtOnce(); listener.OnTouchesBegan = OnTouchesBegan; listener.OnTouchesMoved = OnTouchesMoved; listener.OnTouchesEnded = OnTouchesEnded; AddEventListener(listener); coloredBackground = new CCLayerColor(new CCColor4B(127, 127, 127, 255)); AddChild(coloredBackground, 4); }
public CCMenuItemLabelAtlas(CCLabelAtlas labelAtlas, Action<object> target = null) : base(target) { LabelAtlas = labelAtlas; }
/// <summary> /// Initialize CCStats. /// </summary> public void Initialize () { if (!isInitialized) { // There is a special case for Xamarin iOS monotouch on emulator where they aggresively call // garbage collection themselves on the simulator. This should not affect the devices though. // So we check if we are running on a Device and only update the counters if we are. #if IOS if (Runtime.Arch != Arch.DEVICE) isCheckGC = false; #endif CCTexture2D texture; CCTextureCache textureCache = CCTextureCache.SharedTextureCache; stopwatch = new Stopwatch (); try { var surfaceFormat = CCSurfaceFormat.Bgra4444; #if WINDOWS_PHONE81 surfaceFormat = CCSurfaceFormat.Color; #endif texture = !textureCache.Contains ("cc_fps_images") ? textureCache.AddImage (CCFPSImage.PngData, "cc_fps_images", surfaceFormat) : textureCache ["cc_fps_images"]; // Analysis disable CompareOfFloatsByEqualityOperator if (texture == null || (texture.ContentSizeInPixels.Width == 0 && texture.ContentSizeInPixels.Height == 0)) { CCLog.Log ("CCStats: Failed to create stats texture"); return; } } catch (Exception ex) { // MonoGame may not allow texture.fromstream, // so catch this exception here and disable the stats CCLog.Log ("CCStats: Failed to create stats texture:"); if (ex != null) CCLog.Log (ex.ToString ()); return; } // We will remove the texture cc_fps_images from our cache to fix a problem of loosing the texture // when the cache is purged. If not then the statistics no longer show because it has been Disposed of. textureCache.RemoveTextureForKey ("cc_fps_images"); try { texture.IsAntialiased = false; // disable antialiasing so the labels are always sharp fpsLabel = new CCLabelAtlas ("00.0", texture, 4, 8, '.'); updateTimeLabel = new CCLabelAtlas ("0.000", texture, 4, 8, '.'); drawTimeLabel = new CCLabelAtlas ("0.000", texture, 4, 8, '.'); drawCallLabel = new CCLabelAtlas ("000", texture, 4, 8, '.'); memoryLabel = new CCLabelAtlas ("0", texture, 4, 8, '.'); memoryLabel.Color = new CCColor3B (35, 185, 255); gcLabel = new CCLabelAtlas ("0", texture, 4, 8, '.'); gcLabel.Color = new CCColor3B (255, 196, 54); } catch (Exception ex) { CCLog.Log ("CCStats: Failed to create stats labels:"); if (ex != null) CCLog.Log (ex.ToString ()); return; } } isInitialized = true; Scale = 1; }
// Initialize the stats display. public void Initialize() { if (!isInitialized) { // There is a special case for Xamarin iOS monotouch on emulator where they aggresively call // garbage collection themselves on the simulator. This should not affect the devices though. // So we check if we are running on a Device and only update the counters if we are. #if IOS if (Runtime.Arch != Arch.DEVICE) { isCheckGC = false; } #endif CCTexture2D texture; CCTextureCache textureCache = CCTextureCache.SharedTextureCache; stopwatch = new Stopwatch(); try { texture = !textureCache.Contains("cc_fps_images") ? textureCache.AddImage(CCFPSImage.PngData, "cc_fps_images", CCSurfaceFormat.Bgra4444) : textureCache["cc_fps_images"]; if (texture == null || (texture.ContentSizeInPixels.Width == 0 && texture.ContentSizeInPixels.Height == 0)) { CCLog.Log("CCStats: Failed to create stats texture"); return; } } catch (Exception ex) { // MonoGame may not allow texture.fromstream, // so catch this exception here and disable the stats CCLog.Log("CCStats: Failed to create stats texture:"); if (ex != null) { CCLog.Log(ex.ToString()); } return; } try { texture.IsAntialiased = false; // disable antialiasing so the labels are always sharp fpsLabel = new CCLabelAtlas("00.0", texture, 4, 8, '.'); updateTimeLabel = new CCLabelAtlas("0.000", texture, 4, 8, '.'); drawTimeLabel = new CCLabelAtlas("0.000", texture, 4, 8, '.'); drawCallLabel = new CCLabelAtlas("000", texture, 4, 8, '.'); memoryLabel = new CCLabelAtlas("0", texture, 4, 8, '.'); memoryLabel.Color = new CCColor3B(35, 185, 255); gcLabel = new CCLabelAtlas("0", texture, 4, 8, '.'); gcLabel.Color = new CCColor3B(255, 196, 54); } catch (Exception ex) { CCLog.Log("CCStats: Failed to create stats labels:"); if (ex != null) { CCLog.Log(ex.ToString()); } return; } } var factor = 1.0f; var pos = CCPoint.Zero; //CCApplication.SharedApplication.MainWindowDirector.VisibleOrigin; fpsLabel.Scale = factor; updateTimeLabel.Scale = factor; drawTimeLabel.Scale = factor; drawCallLabel.Scale = factor; memoryLabel.Scale = factor; gcLabel.Scale = factor; memoryLabel.Position = new CCPoint(4 * factor, 44 * factor) + pos; gcLabel.Position = new CCPoint(4 * factor, 36 * factor) + pos; drawCallLabel.Position = new CCPoint(4 * factor, 28 * factor) + pos; updateTimeLabel.Position = new CCPoint(4 * factor, 20 * factor) + pos; drawTimeLabel.Position = new CCPoint(4 * factor, 12 * factor) + pos; fpsLabel.Position = new CCPoint(4 * factor, 4 * factor) + pos; isInitialized = true; }
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)); }
// Initialize the stats display. public void Initialize() { if (!isInitialized) { // There is a special case for Xamarin iOS monotouch on emulator where they aggresively call // garbage collection themselves on the simulator. This should not affect the devices though. // So we check if we are running on a Device and only update the counters if we are. #if IOS if (Runtime.Arch != Arch.DEVICE) isCheckGC = false; #endif CCTexture2D texture; CCTextureCache textureCache = CCTextureCache.SharedTextureCache; stopwatch = new Stopwatch(); try { texture = !textureCache.Contains ("cc_fps_images") ? textureCache.AddImage (CCFPSImage.PngData, "cc_fps_images", CCSurfaceFormat.Bgra4444) : textureCache["cc_fps_images"]; if (texture == null || (texture.ContentSizeInPixels.Width == 0 && texture.ContentSizeInPixels.Height == 0)) { CCLog.Log ("CCStats: Failed to create stats texture"); return; } } catch (Exception ex) { // MonoGame may not allow texture.fromstream, // so catch this exception here and disable the stats CCLog.Log ("CCStats: Failed to create stats texture:"); if(ex!=null) CCLog.Log (ex.ToString ()); return; } try { texture.IsAntialiased = false; // disable antialiasing so the labels are always sharp fpsLabel = new CCLabelAtlas ("00.0", texture, 4, 8, '.'); updateTimeLabel = new CCLabelAtlas ("0.000", texture, 4, 8, '.'); drawTimeLabel = new CCLabelAtlas ("0.000", texture, 4, 8, '.'); drawCallLabel = new CCLabelAtlas ("000", texture, 4, 8, '.'); memoryLabel = new CCLabelAtlas ("0", texture, 4, 8, '.'); memoryLabel.Color = new CCColor3B (35, 185, 255); gcLabel = new CCLabelAtlas ("0", texture, 4, 8, '.'); gcLabel.Color = new CCColor3B (255, 196, 54); } catch (Exception ex) { CCLog.Log ("CCStats: Failed to create stats labels:"); if(ex !=null) CCLog.Log (ex.ToString ()); return; } } var factor = 2; var pos = CCPoint.Zero; fpsLabel.Scale = factor; updateTimeLabel.Scale = factor; drawTimeLabel.Scale = factor; drawCallLabel.Scale = factor; memoryLabel.Scale = factor; gcLabel.Scale = factor; memoryLabel.Position = new CCPoint (4 * factor, 44 * factor) + pos; gcLabel.Position = new CCPoint (4 * factor, 36 * factor) + pos; drawCallLabel.Position = new CCPoint (4 * factor, 28 * factor) + pos; updateTimeLabel.Position = new CCPoint (4 * factor, 20 * factor) + pos; drawTimeLabel.Position = new CCPoint (4 * factor, 12 * factor) + pos; fpsLabel.Position = new CCPoint (4 * factor, 4 * factor) + pos; isInitialized = true; }
/// <summary> /// Initialize CCStats. /// </summary> public void Initialize() { if (!isInitialized) { // There is a special case for Xamarin iOS monotouch on emulator where they aggresively call // garbage collection themselves on the simulator. This should not affect the devices though. // So we check if we are running on a Device and only update the counters if we are. #if IOS if (Runtime.Arch != Arch.DEVICE) { isCheckGC = false; } #endif CCTexture2D texture; CCTextureCache textureCache = CCTextureCache.SharedTextureCache; stopwatch = new Stopwatch(); try { texture = !textureCache.Contains("cc_fps_images") ? textureCache.AddImage(CCFPSImage.PngData, "cc_fps_images", CCSurfaceFormat.Bgra4444) : textureCache ["cc_fps_images"]; // Analysis disable CompareOfFloatsByEqualityOperator if (texture == null || (texture.ContentSizeInPixels.Width == 0 && texture.ContentSizeInPixels.Height == 0)) { CCLog.Log("CCStats: Failed to create stats texture"); return; } } catch (Exception ex) { // MonoGame may not allow texture.fromstream, // so catch this exception here and disable the stats CCLog.Log("CCStats: Failed to create stats texture:"); if (ex != null) { CCLog.Log(ex.ToString()); } return; } // We will remove the texture cc_fps_images from our cache to fix a problem of loosing the texture // when the cache is purged. If not then the statistics no longer show because it has been Disposed of. textureCache.RemoveTextureForKey("cc_fps_images"); try { texture.IsAntialiased = false; // disable antialiasing so the labels are always sharp fpsLabel = new CCLabelAtlas("00.0", texture, 4, 8, '.'); updateTimeLabel = new CCLabelAtlas("0.000", texture, 4, 8, '.'); drawTimeLabel = new CCLabelAtlas("0.000", texture, 4, 8, '.'); drawCallLabel = new CCLabelAtlas("000", texture, 4, 8, '.'); memoryLabel = new CCLabelAtlas("0", texture, 4, 8, '.'); memoryLabel.Color = new CCColor3B(35, 185, 255); gcLabel = new CCLabelAtlas("0", texture, 4, 8, '.'); gcLabel.Color = new CCColor3B(255, 196, 54); } catch (Exception ex) { CCLog.Log("CCStats: Failed to create stats labels:"); if (ex != null) { CCLog.Log(ex.ToString()); } return; } } isInitialized = true; Scale = 1; }
public virtual void initWithSubTest(int asubtest, int particles) { //srandom(0); subtestNumber = asubtest; CCSize s = Layer.VisibleBoundsWorldspace.Size; lastRenderedCount = 0; quantityParticles = particles; CCMenuItemFont.FontSize = 64; CCMenuItemFont.FontName = "arial"; CCMenuItemFont decrease = new CCMenuItemFont(" - ", onDecrease); decrease.Color = new CCColor3B(0, 200, 20); CCMenuItemFont increase = new CCMenuItemFont(" + ", onIncrease); increase.Color = new CCColor3B(0, 200, 20); CCMenu menu = new CCMenu(decrease, increase); menu.AlignItemsHorizontally(); menu.Position = new CCPoint(s.Width / 2, s.Height / 2 + 15); AddChild(menu, 1); CCLabelTtf infoLabel = new CCLabelTtf("0 nodes", "Marker Felt", 30); infoLabel.Color = new CCColor3B(0, 200, 20); infoLabel.Position = new CCPoint(s.Width / 2, s.Height - 90); AddChild(infoLabel, 1, PerformanceParticleTest.kTagInfoLayer); // particles on stage CCLabelAtlas labelAtlas = new CCLabelAtlas("0000", "Images/fps_Images", 12, 32, '.'); AddChild(labelAtlas, 0, PerformanceParticleTest.kTagLabelAtlas); labelAtlas.Position = new CCPoint(s.Width - 66, 50); // Next Prev Test ParticleMenuLayer pMenu = new ParticleMenuLayer(true, PerformanceParticleTest.TEST_COUNT, PerformanceParticleTest.s_nParCurIdx); AddChild(pMenu, 1, PerformanceParticleTest.kTagMenuLayer); // Sub Tests CCMenuItemFont.FontSize = 38; CCMenuItemFont.FontName = "arial"; CCMenu pSubMenu = new CCMenu(null); for (int i = 1; i <= 6; ++i) { //char str[10] = {0}; string str; //sprintf(str, "%d ", i); str = string.Format("{0:G}", i); CCMenuItemFont itemFont = new CCMenuItemFont(str, testNCallback); itemFont.Tag = i; pSubMenu.AddChild(itemFont, 10); if (i <= 3) { itemFont.Color = new CCColor3B(200, 20, 20); } else { itemFont.Color = new CCColor3B(0, 200, 20); } } pSubMenu.AlignItemsHorizontally(); pSubMenu.Position = new CCPoint(s.Width / 2, 80); AddChild(pSubMenu, 2); CCLabelTtf label = new CCLabelTtf(title(), "arial", 38); AddChild(label, 1); label.Position = new CCPoint(s.Width / 2, s.Height - 32); label.Color = new CCColor3B(255, 255, 40); updateQuantityLabel(); createParticleSystem(); Schedule(step); }
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. 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 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 var item4 = new CCMenuItemFont("I toggle enable items", (sender) => { disabledItem.Enabled = !disabledItem.Enabled; }); // Label Item (CCLabelBMFont) var label = new CCLabel("configuration", "fonts/bitmapFontTest3.fnt"); var item5 = new CCMenuItemLabel(label, this.menuCallbackConfig); // Testing issue #500 item5.Scale = 0.8f; CCMenuItemFont.FontSize = 30; // Events var item6 = new CCMenuItemFont("Priority Test", menuCallbackPriorityTest); // Font Item var 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 var 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++; } } }