public IntroLayer() : base(CCColor4B.Red) { // create and initialize a Label CCSimpleAudioEngine.SharedEngine.PreloadEffect("bgm/title"); for (int i = 0; i < 4; i++) //Arreglo error al repetir tablero { if (GameData.pos[i] == 0) GameData.pos[i] = 1; } label = new CCLabel("Bienvenido a bordo. Seleccione cuantos jugadores van a jugar, y luego presione aqui.", "fonts/MarkerFelt", 22, CCLabelFormat.SpriteFont); AgregarFondo(); AgregarPersonajes(); // add the label as a child to this Layer AddChild(label); twoplayerlabels=new CCLabel("2 jugadores", "fonts/MarkerFelt", 22, CCLabelFormat.SpriteFont); twoplayerlabels.Color = CCColor3B.Green; AddChild(twoplayerlabels); threeplayerlabel= new CCLabel("3 jugadores", "fonts/MarkerFelt", 22, CCLabelFormat.SpriteFont); threeplayerlabel.Color = CCColor3B.Green; AddChild(threeplayerlabel); fourplayerLabel=new CCLabel("4 jugadores", "fonts/MarkerFelt", 22, CCLabelFormat.SpriteFont); fourplayerLabel.Color = CCColor3B.Green; AddChild(fourplayerLabel); CCSimpleAudioEngine.SharedEngine.PreloadEffect(startsound); CCSimpleAudioEngine.SharedEngine.PreloadEffect(coinsound); CCSimpleAudioEngine.SharedEngine.PreloadEffect(selectsound); }
//^Each character needed it's own CCSprite to go with a weapon, only one instance of a CCSprite shows in game public GameLayer() : base("level_" + CCRandom.GetRandomInt(3, numLevels) + ".tmx"/*"level_5.tmx"*/) // get a random level and load it on initialization { character.map = this; //touch listener - calles tileHandler to handle tile touches touchListener = new CCEventListenerTouchAllAtOnce(); touchListener.OnTouchesEnded = handleEndTouches; AddEventListener(touchListener); loopTiles(null); //Schedule the main game loop enemiesList = placeEnemiesRandomly(); foreach (character enemy in enemiesList) this.AddChild(enemy); //Add labels to the upper left hand corner //Might be better to have a bar with width based on a percentage of health/maxhealth userInfo = new CCLabel ("Health: " + user.health + "/" + user.maxHealth + " Attack : " + user.weapon.attack,"arial",12); userInfo.Position = new CCPoint(70, VisibleBoundsWorldspace.UpperRight.Y + 5); userInfo.IsAntialiased = true; this.AddChild(userInfo); //run main game loop - frames happen every 1 second Schedule(RunGameLogic,(float)0.5); }
public CCControlSwitch(CCSprite maskSprite, CCSprite onSprite, CCSprite offSprite, CCSprite thumbSprite, CCLabel onLabel, CCLabel offLabel) { 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."); on = true; switchSprite = new CCControlSwitchSprite(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; // Register Touch Event var touchListener = new CCEventListenerTouchOneByOne(); touchListener.IsSwallowTouches = true; touchListener.OnTouchBegan = OnTouchBegan; touchListener.OnTouchMoved = OnTouchMoved; touchListener.OnTouchEnded = OnTouchEnded; touchListener.OnTouchCancelled = OnTouchCancelled; AddEventListener(touchListener); }
private bool InitOrientationTest () { bool bRet = false; do { CCSize s = Layer.VisibleBoundsWorldspace.Size; var label = new CCLabel(title(), "Arial", 26, CCLabelFormat.SpriteFont); AddChild(label, 1); label.Position = new CCPoint(s.Width / 2, s.Height - 50); string sSubtitle = subtitle(); if (sSubtitle.Length > 0) { var l = new CCLabel(sSubtitle, "Arial", 16, CCLabelFormat.SpriteFont); 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 = s.Center; 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); bRet = true; } while (false); return bRet; }
public override void OnEnter() { base.OnEnter(); CCSize s = Layer.VisibleBoundsWorldspace.Size; var label = new CCLabel(title(), "arial", 26, CCLabelFormat.SpriteFont); AddChild(label, 1); label.Position = (new CCPoint(s.Width / 2, s.Height - 50)); string strSubTitle = subtitle(); if (strSubTitle.Length > 0) { var l = new CCLabel(strSubTitle, "Thonburi", 16, CCLabelFormat.SpriteFont); 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(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 LabelFNTMultiLine() { CCSize s; // Left label1 = new CCLabel("Multi line\nLeft", "fonts/bitmapFontTest3.fnt"); label1.AnchorPoint = new CCPoint(0, 0); AddChild(label1, 0, (int)TagSprite.kTagBitmapAtlas1); s = label1.ContentSize; CCLog.Log("content size label1: {0,0:f2} x {1,0:f2}", s.Width, s.Height); // Center label2 = new CCLabel("Multi line\nCenter", "fonts/bitmapFontTest3.fnt"); label2.AnchorPoint = new CCPoint(0.5f, 0.5f); AddChild(label2, 0, (int)TagSprite.kTagBitmapAtlas2); s = label2.ContentSize; CCLog.Log("content size label2: {0,0:f2} x {1,0:f2}", s.Width, s.Height); // right label3 = new CCLabel("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.Log("content size labe3: {0,0:f2} x {1,0:f2}", s.Width, s.Height); }
private void InitUI() { var title = new CCLabel("冒险与编程", StringManager.GetText("GlobalFont"), 72) { Position = new CCPoint(400, 320), Color = CCColor3B.Yellow }; AddChild(title, 100); var begin = new CozySampleButton(200, 100, 200, 80) { // 测试代码 // Text = "开始游戏", Text = StringManager.GetText("str3"), FontSize = 24, OnClick = new Action(OnBeginButtonDown), }; AddChild(begin, 100); dispatcher.Add(begin); var reg = new CozySampleButton(690, 0, 100, 50) { Text = "注册帐号", FontSize = 18, OnClick = new Action(OnRegisterButton), }; AddChild(reg, 100); dispatcher.Add(reg); }
public override void OnEnter () { base.OnEnter (); var origin = Layer.VisibleBoundsWorldspace.Size; var label1 = new CCLabel(string.Empty, "debuguncompressed", 0, CCLabelFormat.SpriteFont); var texture = label1.TextureAtlas != null ? label1.TextureAtlas.Texture : null; if (texture != null) { spriteFontNode = new CCSprite (texture); spriteFontNode.Scale = 2; } else { spriteFontNode = new CCLabel("Texture can not be loaded", "arial", 24, CCLabelFormat.SpriteFont); } //spriteFontNode.Color = CCColor3B.Magenta; spriteFontNode.Position = origin.Center; AddChild (spriteFontNode); var itemUncompressed = new CCMenuItemLabel(new CCLabel("Uncompressed", "fonts/arial", 24, CCLabelFormat.SpriteFont)); var itemCompressed = new CCMenuItemLabel(new CCLabel("Compressed", "fonts/arial", 24, CCLabelFormat.SpriteFont)); itemUncompressed.AnchorPoint = CCPoint.AnchorMiddleLeft; itemCompressed.AnchorPoint = CCPoint.AnchorMiddleLeft; var mi1 = new CCMenuItemToggle(OnToggle, itemUncompressed, itemCompressed); var menu = new CCMenu(mi1); AddChild(menu); menu.Position = VisibleBoundsWorldspace.Left(); }
public IntroLayer() : base(CCColor4B.Gray) { titleLabel = new CCLabel("CocosJuce", "fonts/Roboto-Light-72.fnt"); frequencyLabel = new CCLabel("", "fonts/Roboto-Light-72.fnt"); onOffSwitchSpriteFrameCache = CCSpriteFrameCache.SharedSpriteFrameCache; onOffSwitchSpriteFrameCache.AddSpriteFrames("images/onoffswitch.plist"); switchOnSprite = new CCSprite("switch_on.png"); switchOffSprite = new CCSprite("switch_off.png"); onOffSwitch = new CCMenuItemToggle(SwitchToggle, new CCMenuItem[] { new CCMenuItemImage(switchOffSprite) { }, new CCMenuItemImage(switchOnSprite) { }, }); menu = new CCMenu(onOffSwitch); freqKnobSpriteFrameCache = CCSpriteFrameCache.SharedSpriteFrameCache; freqKnobSpriteFrameCache.AddSpriteFrames("images/frequencyknob.plist"); frequencyKnob = new CCSprite("frequencyknob00.png"); AddChild(titleLabel); AddChild(menu); AddChild(frequencyLabel); AddChild(frequencyKnob); }
public override void OnEnter() { base.OnEnter(); //Configure control panel //Our hero initialization hero = new Hero(); InitializePlayer(hero, actors, new CCPoint(100, 100)); //Hero information life = GetLabel(""); life.Position = hero.GetLifePosition(LifePosition.Up); //new CCPoint( .WindowSizeInPixels.Width * .5f, Director.WindowSizeInPixels.Height * .95f); AddChild(life); //Initialization Enemies for (int i = 0; i < ROBOTS; i++) InitializeEnemy(new Robot(), actors); controlPanelLayer.ScaleX = controlPanelLayer.ScaleY = .7f; controlPanelLayer.JoyControl.Position = new CCPoint(-10, -10); SetViewPointCenter(hero.Position); Schedule(); }
public CCControlScene() { SceneTitleLabel = new CCLabel(" ", "Arial", 12, CCLabelFormat.SpriteFont); AddChild(SceneTitleLabel, 1); }
public override void OnEnter () { base.OnEnter (); CCSize s = Layer.VisibleBoundsWorldspace.Size; Box2DView view = Box2DView.viewWithEntryID(m_entryID); AddChild(view, 0, kTagBox2DNode); view.Scale = 8; view.AnchorPoint = new CCPoint(0, 0); view.Position = new CCPoint(s.Width / 2, s.Height / 4); //#if (CC_TARGET_PLATFORM == CC_PLATFORM_MARMALADE) // CCLabelBMFont* label = new CCLabelBMFont(view.title().c_str(), "fonts/arial16.fnt"); //#else var label = new CCLabel(view.title(), "arial", 18, CCLabelFormat.SpriteFont); //#endif AddChild(label, 1); label.Position = new CCPoint(s.Width / 2, s.Height - 30); 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 = 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 IntroLayer() : base(CCColor4B.White) { redChair = new CCSprite("images/silla_red.png"); blueChair = new CCSprite("images/silla_blue.png"); greenChair = new CCSprite("images/silla_green.png"); magentaChair = new CCSprite("images/silla_magenta.png"); cyanChair = new CCSprite("images/silla_cyan.png"); orangeChair = new CCSprite("images/silla_orange.png"); sillas.Add(redChair); sillas.Add(blueChair); sillas.Add(greenChair); sillas.Add(magentaChair); sillas.Add(cyanChair); sillas.Add(orangeChair); AddChild(redChair); AddChild(blueChair); AddChild(greenChair); AddChild(magentaChair); AddChild(cyanChair); AddChild(orangeChair); // create and initialize a Label label = new CCLabel("Silla Musical", "fonts/MarkerFelt", 22, CCLabelFormat.SpriteFont); // add the label as a child to this Layer AddChild(label); }
public override void OnEnter() { base.OnEnter(); // ask director the the window size var size = VisibleBoundsWorldspace.Size; arrowsWidth = (ArrowsMax - ArrowsMin) * size.Width; arrowsWidthCenter = arrowsWidth * 0.5f; // create and initialize a Label label = new CCLabel("Test\nLine\nHeight", "fonts/arial-unicode-26.fnt"); label.Color = CCColor3B.Red; arrowsBar = new CCSprite("Images/arrowsBar"); arrows = new CCSprite("Images/arrows"); arrows.Color = CCColor3B.Blue; // position the label on the center of the screen label.Position = size.Center; arrowsBar.Visible = false; arrowsBar.ScaleX = (arrowsWidth / arrowsBar.ContentSize.Width); arrowsBar.Position = new CCPoint(size.Width / 2.0f, size.Height * 0.15f + arrowsBar.ContentSize.Height * 2.0f); snapArrowsToEdge(); AddChild(label); AddChild(arrowsBar); AddChild(arrows); }
public LabelSFOldNew() { // CCLabel SpriteFont label1 = new CCLabel("SpriteFont Label Test", "arial", 48, CCLabelFormat.SpriteFont); AddChild(label1); label2 = new CCLabelTtf("SpriteFont Label Test", "arial", 48); label2.Color = CCColor3B.Red; label2.AnchorPoint = CCPoint.AnchorMiddle; 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 static CCNode CreateLabel(string text, float size, CCColor3B color, CCColor3B shadowColor) { var node = new CCNode () { AnchorPoint = CCPoint.AnchorMiddle, }; size *= 1.2f; var lbl = new CCLabel(text, "fonts/MorrisRoman-Black.ttf", size, CCLabelFormat.SystemFont) { Color = color, AnchorPoint = CCPoint.AnchorMiddle, }; lbl.LabelFormat.Alignment = CCTextAlignment.Center; node.ContentSize = lbl.ScaledContentSize; lbl.Position = node.ContentSize.Center; if (shadowColor != CCColor3B.Magenta) { node.ContentSize = lbl.ContentSize + 2; var shadowLbl = new CCLabel (text, "fonts/MorrisRoman-Black.ttf", size, CCLabelFormat.SystemFont) { Color = shadowColor, AnchorPoint = CCPoint.AnchorMiddle, Position = new CCPoint(node.ContentSize.Center.X + 2, node.ContentSize.Center.Y - 2) }; shadowLbl.LabelFormat.Alignment = CCTextAlignment.Center; node.AddChild (shadowLbl); } node.AddChild (lbl); return node; }
public LabelFNTPadding() { label = new CCLabel("abcdefg", "fonts/bitmapFontTest4.fnt"); AddChild(label); label.AnchorPoint = CCPoint.AnchorMiddle; }
public override void OnEnter() { base.OnEnter(); var size = Layer.VisibleBoundsWorldspace.Size; var labelFormatCenter = CCLabelFormat.SystemFont; labelFormatCenter.Alignment = CCTextAlignment.Center; for (var i=0;i < fontList.Length; ++i) { var label = new CCLabel(fontList[i], fontList[i], 20, labelFormatCenter); if( label != null) { label.Position = size.Center; label.PositionY = ((size.Height * 0.6f) / fontList.Length * i) + (size.Height/5f); AddChild(label); } else { CCLog.Log ("ERROR: Cannot load: %s", fontList[i]); } } }
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 SeleccionJuego() : base(CCColor4B.Blue) { // create and initialize a Label label = new CCLabel("Selecciona un juego!", "fonts/MarkerFelt", 22, CCLabelFormat.SpriteFont); AgregarFondo(); // add the label as a child to this Layer AddChild(label); sillasLabel = new CCLabel("Sillas musicales", "fonts/MarkerFelt", 22, CCLabelFormat.SpriteFont); sillasLabel.Color = CCColor3B.Blue; AddChild(sillasLabel); dictadoLabel = new CCLabel("Nombre no definido", "fonts/MarkerFelt", 22, CCLabelFormat.SpriteFont); dictadoLabel.Color = CCColor3B.Green; AddChild(dictadoLabel); maletaLabel = new CCLabel("Maletas " , "fonts/MarkerFelt", 22, CCLabelFormat.SpriteFont); maletaLabel.Color = CCColor3B.Yellow; AddChild(maletaLabel); tableroLabel = new CCLabel("Tablero ", "fonts/MarkerFelt", 22, CCLabelFormat.SpriteFont); tableroLabel.Color = CCColor3B.Red; AddChild(tableroLabel); CCSimpleAudioEngine.SharedEngine.PreloadEffect(startsound); CCSimpleAudioEngine.SharedEngine.PreloadEffect(coinsound); CCSimpleAudioEngine.SharedEngine.PreloadEffect(selectsound); }
protected override void AddedToScene () { base.AddedToScene (); Scene.SceneResolutionPolicy = CCSceneResolutionPolicy.ShowAll; var scoreLabel = new CCLabel (scoreMessage, "HelveticaNeue-Bold", 32 * (sx > sy ? sx : sy)) { Position = new CCPoint (VisibleBoundsWorldspace.Size.Center.X, VisibleBoundsWorldspace.Size.Center.Y + 50), Color = new CCColor3B (CCColor4B.Yellow), HorizontalAlignment = CCTextAlignment.Center, VerticalAlignment = CCVerticalTextAlignment.Center, AnchorPoint = CCPoint.AnchorMiddle }; AddChild (scoreLabel); var playAgainLabel = new CCLabel ("Tap to Play Again", "HelveticaNeue-Bold", 32 * (sx > sy ? sx : sy)) { Position = new CCPoint (VisibleBoundsWorldspace.Size.Center.X, VisibleBoundsWorldspace.Size.Center.Y - 50 * sy), Color = new CCColor3B (CCColor4B.Green), HorizontalAlignment = CCTextAlignment.Center, VerticalAlignment = CCVerticalTextAlignment.Center, AnchorPoint = CCPoint.AnchorMiddle }; AddChild (playAgainLabel); AddMonkey (); }
/// <summary> /// Initializes a new instance of the <see cref="Client.Common.Views.DebugLayer"/> class. /// </summary> public DebugLayer() : base() { Position = VisibleBoundsWorldspace.LowerLeft; AnchorPoint = CCPoint.AnchorLowerLeft; m_label = new CCLabel(string.Empty, "verdana", 12) { Position = VisibleBoundsWorldspace.LowerLeft, Color = CCColor3B.Black, HorizontalAlignment = CCTextAlignment.Left, VerticalAlignment = CCVerticalTextAlignment.Top, AnchorPoint = CCPoint.AnchorLowerLeft, Dimensions = VisibleBoundsWorldspace.Size }; Color = CCColor3B.White; Opacity = 255; AddChild(m_label); Visible = false; TouchHandler.Instance.ListenEnded(this, new Func<List<CCTouch>, CCEvent, bool>(OnTouchesEnded)); TouchHandler.Instance.ListenBegan(this, new Func<List<CCTouch>, CCEvent, bool>(OnTouchesCatch)); TouchHandler.Instance.ListenMoved(this, new Func<List<CCTouch>, CCEvent, bool>(OnTouchesCatch)); TouchHandler.Instance.ListenCancelled(this, new Func<List<CCTouch>, CCEvent, bool>(OnTouchesCatch)); }
public CampUiLayer() { var edit = new CCLabel("战斗力:"+Fighting+"金币"+Gold+"经验"+Exper, "微软雅黑", 22) { Position = new CCPoint(100, 120), Color = CCColor3B.Blue }; AddChild(edit, 100); var Goon = new CozySampleButton(631, 86, 78, 36) { Text = "继续冒险", FontSize = 14 }; AddChild(Goon, 100); var MercMange = new CozySampleButton(631, 160, 78, 36) { Text = "佣兵管理", FontSize = 14 }; AddChild(MercMange, 100); var MyGoods = new CozySampleButton(631, 227, 78, 36) { Text = "我的物品", FontSize = 14 }; AddChild(MyGoods, 100); var MyFriends = new CozySampleButton(631, 299, 78, 36) { Text = "我的好友", FontSize = 14 }; AddChild(MyFriends, 100); }
private void CreateHowtoLabel() { float backgroundWidth = howToImage.ScaledContentSize.Width; const float backgroundHeight = 36; labelBackground = new CCDrawNode (); var rect = new CCRect ( -backgroundWidth / 2.0f, -backgroundHeight / 2.0f, backgroundWidth , backgroundHeight ); labelBackground.DrawRect ( rect, CCColor4B.Black); labelBackground.PositionX = ContentSize.Center.X; labelBackground.PositionY = 74; mainLayer.AddChild (labelBackground); howToLabel = new CCLabel( "Touch and move on the left side of the screen to move.\nTap on the right side to jump.", "fonts/Aldrich-Regular.ttf", 12, CCLabelFormat.SystemFont); howToLabel.PositionX = ContentSize.Center.X; howToLabel.Scale = .5f; howToLabel.PositionY = 74; howToLabel.HorizontalAlignment = CCTextAlignment.Center; howToLabel.VerticalAlignment = CCVerticalTextAlignment.Center; howToLabel.IsAntialiased = false; mainLayer.AddChild (howToLabel); }
public GameScene(CCWindow mainWindow) : base(mainWindow) { mainLayer = new CCLayer (); AddChild (mainLayer); paddleSprite = new CCSprite ("paddle"); paddleSprite.PositionX = 100; paddleSprite.PositionY = 100; mainLayer.AddChild (paddleSprite); ballSprite = new CCSprite ("ball"); ballSprite.PositionX = 320; ballSprite.PositionY = 600; mainLayer.AddChild (ballSprite); scoreLabel = new CCLabel ("Score: 0", "arial", 22); scoreLabel.PositionX = mainLayer.VisibleBoundsWorldspace.MinX + 20; scoreLabel.PositionY = mainLayer.VisibleBoundsWorldspace.MaxY - 20; scoreLabel.AnchorPoint = CCPoint.AnchorUpperLeft; mainLayer.AddChild (scoreLabel); Schedule (RunGameLogic); touchListener = new CCEventListenerTouchAllAtOnce (); touchListener.OnTouchesMoved = HandleTouchesMoved; AddEventListener (touchListener, this); }
public LoadingUiLayer() { //logo = new CCSprite("@face.png") //{ // Position = new CCPoint(381, 154), //}; //AddChild(logo); label = new CCLabel("加载中", "微软雅黑", 24) { Position = new CCPoint(381, 220), }; AddChild(label, 100); load = new CCLabel("程序员正在加班写代码", "微软雅黑", 20) { AnchorPoint = CCPoint.Zero, Position = new CCPoint(250, 150), }; AddChild(load, 100); Schedule(OnChangeText, 1.0f); Schedule(OnTimeOut, 10.0f); AppDelegate.MessageReceiveEventHandler += OnMessage; UserLogic.Login("kingwl", "123456"); }
public LoginUiLayer() { var title = new CCLabel("冒险与编程", "微软雅黑", 72) { Position = new CCPoint(400, 320), Color = CCColor3B.Yellow }; AddChild(title, 100); var begin = new CozySampleButton(300, 100, 200, 80) { Text = "开始游戏", FontSize = 24, OnClick = new Action(OnBeginButtonDown), }; AddEventListener(begin.EventListener); AddChild(begin, 100); var reg = new CozySampleButton(690, 0, 100, 50) { Text = "注册帐号", FontSize = 18, OnClick = new Action(OnRegisterButton), }; AddEventListener(reg.EventListener); AddChild(reg, 100); }
public GameLayer() { // "paddle" refers to the paddle.png image. paddleSprite = new CCSprite ("paddle"); paddleSprite.PositionX = 180; paddleSprite.PositionY = 100; AddChild (paddleSprite); ballSprite = new CCSprite ("ball"); ballSprite.PositionX = 180; ballSprite.PositionY = 600; AddChild (ballSprite); scoreLabel = new CCLabel ("Score: 0", "arial", 28, CCLabelFormat.SystemFont); scoreLabel.PositionX = 50; scoreLabel.PositionY = 480; scoreLabel.AnchorPoint = CCPoint.AnchorUpperLeft; AddChild (scoreLabel); highestScoreLabel = new CCLabel ("Highest Score: 0", "arial", 28, CCLabelFormat.SystemFont); highestScoreLabel.PositionX = 50; highestScoreLabel.PositionY = 500; highestScoreLabel.AnchorPoint = CCPoint.AnchorUpperLeft; AddChild (highestScoreLabel); Schedule (RunGameLogic); }
public RenderTextureZbuffer() { label = new CCLabel("vertexZ = 50", "Marker Felt", 32, CCLabelFormat.SpriteFont); AddChild(label); label2 = new CCLabel("vertexZ = 0", "Marker Felt", 32, CCLabelFormat.SpriteFont); AddChild(label2); label3 = new CCLabel("vertexZ = -50", "Marker Felt", 32, CCLabelFormat.SpriteFont); AddChild(label3); CCSpriteFrameCache.SharedSpriteFrameCache.AddSpriteFrames("Images/bugs/circle.plist"); 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"); AddChild(sp1, 9); AddChild(sp2, 8); AddChild(sp3, 7); AddChild(sp4, 6); AddChild(sp5, 5); AddChild(sp6, 4); AddChild(sp7, 3); AddChild(sp8, 2); AddChild(sp9, 1); sp9.Color = CCColor3B.Yellow; }
public PopUpLayer(CCSprite background, CCLabel title) { mBackgroundImage = background; mTitle = title; CreateLayer (); }
public StartScene(CCWindow mainWindow) : base(mainWindow) { mainLayer = new CCLayer (); AddChild (mainLayer); PlayButton = new CCSprite ("logo"); NameLabel = new CCLabel ("Map Knight - Alpha", "arial", 22); CreatorLabel = new CCLabel ("Created by tipfom and Exo", "arial", 22); VersionLabel = new CCLabel ("Version unspecified", "arial", 22); InfoLabel = new CCLabel ("Click to play", "arial", 22); PlayButton.ScaleX = mainWindow.WindowSizeInPixels.Width / PlayButton.ContentSize.Width; PlayButton.ScaleY = mainWindow.WindowSizeInPixels.Height / PlayButton.ContentSize.Height; PlayButton.Position = new CCPoint (PlayButton.ScaledContentSize.Width / 2, PlayButton.ScaledContentSize.Height / 2); NameLabel.Position = new CCPoint (mainWindow.WindowSizeInPixels.Width / 4 * 3, mainWindow.WindowSizeInPixels.Height / 2 - NameLabel.ContentSize.Height); CreatorLabel.Position = new CCPoint (mainWindow.WindowSizeInPixels.Width / 4 * 3, NameLabel.PositionY - CreatorLabel.ContentSize.Height - 30); VersionLabel.Position = new CCPoint (mainWindow.WindowSizeInPixels.Width / 4 * 3, CreatorLabel.PositionY - VersionLabel.ContentSize.Height - 30); InfoLabel.Position = new CCPoint (mainWindow.WindowSizeInPixels.Width / 4 * 3, VersionLabel.PositionY - InfoLabel.ContentSize.Height - 30); mainLayer.AddChild (PlayButton); mainLayer.AddChild (NameLabel); mainLayer.AddChild (CreatorLabel); mainLayer.AddChild (VersionLabel); mainLayer.AddChild (InfoLabel); touchListener = new CCEventListenerTouchAllAtOnce (); touchListener.OnTouchesEnded = HandleTouchesEnded; AddEventListener (touchListener, this); }
public CCTLTextLayout(CCLabel label) { this.label = label; this.fontAtlas = label.FontAtlas; this.font = label.FontAtlas.Font; this.text = label.Text; // Obtain the kernings for the text. ComputeHorizontalKernings(this.text); // Flag the possible line breaks base on the current label text. LineBreak(this.text); }
public CCControlStepper(CCSprite minusSprite, CCSprite plusSprite) { Debug.Assert(minusSprite != null, "Minus sprite must be not nil"); Debug.Assert(plusSprite != null, "Plus sprite must be not nil"); IsContinuous = true; IgnoreAnchorPointForPosition = false; autorepeat = true; minimumValue = 0; maximumValue = 100; value = 0; stepValue = 1; wraps = false; MinusSprite = minusSprite; MinusSprite.Position = minusSprite.ContentSize.Center; AddChild(MinusSprite); MinusLabel = new CCLabel("-", ControlStepperLabelFont, 38); MinusLabel.Color = ControlStepperLabelColorDisabled; MinusLabel.Position = MinusSprite.ContentSize.Center; MinusSprite.AddChild(MinusLabel); PlusSprite = plusSprite; PlusSprite.Position = new CCPoint(minusSprite.ContentSize.Width + plusSprite.ContentSize.Width / 2, minusSprite.ContentSize.Height / 2); AddChild(PlusSprite); PlusLabel = new CCLabel("+", ControlStepperLabelFont, 38); PlusLabel.Color = ControlStepperLabelColorEnabled; PlusLabel.Position = PlusSprite.ContentSize.Center; PlusSprite.AddChild(PlusLabel); // Defines the content size CCRect maxRect = CCControlUtils.CCRectUnion(MinusSprite.BoundingBox, PlusSprite.BoundingBox); ContentSize = new CCSize(MinusSprite.ContentSize.Width + PlusSprite.ContentSize.Height, maxRect.Size.Height); // Register Touch Event var touchListener = new CCEventListenerTouchOneByOne(); touchListener.IsSwallowTouches = true; touchListener.OnTouchBegan = OnTouchBegan; touchListener.OnTouchMoved = OnTouchMoved; touchListener.OnTouchEnded = OnTouchEnded; AddEventListener(touchListener); }
public CCControlSwitchSprite(CCSprite maskSprite, CCSprite onSprite, CCSprite offSprite, CCSprite thumbSprite, CCLabel onLabel, CCLabel offLabel) : base((CCTexture2D)null, new CCRect(0.0f, 0.0f, maskSprite.TextureRectInPixels.Size.Width, maskSprite.TextureRectInPixels.Size.Height)) { OnPosition = 0; OffPosition = -onSprite.ContentSize.Width + thumbSprite.ContentSize.Width / 2; sliderXPosition = OnPosition; OnSprite = onSprite; OffSprite = offSprite; ThumbSprite = thumbSprite; OnLabel = onLabel; OffLabel = offLabel; MaskSprite = maskSprite; AddChild(ThumbSprite); NeedsLayout(); }
public CCMenuItemLabel(CCLabel label, Action <object> target = null) : base(target) { Label = label; }