Example #1
0
        private CCLabelTtf GetMenuLabel(string text) {
            var label = new CCLabelTtf(text, "kongtext", 18) {
                Color = new CCColor3B(180, 180, 250)
            };

            return label;
        }
Example #2
0
        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);

        }
Example #3
0
        public CCControlSwitch(CCSprite maskSprite, CCSprite onSprite, CCSprite offSprite, CCSprite thumbSprite, CCLabelTtf onLabel,
                               CCLabelTtf 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);
        }
Example #4
0
        public override void OnEnter()
        {
            //
            // This test MUST be done in 'onEnter' and not on 'init'
            // otherwise the paused action will be resumed at 'onEnter' time
            //
            base.OnEnter();

            CCSize s = Layer.VisibleBoundsWorldspace.Size;

            CCLabelTtf l = new CCLabelTtf("After 5 seconds grossini should move", "arial", 16);
            AddChild(l);
            l.Position = (new CCPoint(s.Width / 2, 245));


            //
            // Also, this test MUST be done, after [super onEnter]
            //
            CCSprite grossini = new CCSprite(s_pPathGrossini);
            AddChild(grossini, 0, kTagGrossini);
            grossini.Position = (new CCPoint(200, 200));

            CCAction action = new CCMoveBy (1, new CCPoint(150, 0));

            grossini.AddAction(action, true);

            Schedule(unpause, 3);
        }
Example #5
0
        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    
            CCLabelTtf label = new CCLabelTtf(view.title(), "arial", 18);
            //#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);
        }
Example #6
0
        public override void OnEnter()
        {
            base.OnEnter();

            CCSize s = Layer.VisibleBoundsWorldspace.Size;

            CCLabelTtf label = new CCLabelTtf(title(), "arial", 26);
            AddChild(label, 1);
            label.Position = (new CCPoint(s.Width / 2, s.Height - 50));

            string strSubTitle = subtitle();
            if (strSubTitle.Length > 0)
            {
                CCLabelTtf l = new CCLabelTtf(strSubTitle, "Thonburi", 16);
                AddChild(l, 1);
                l.Position = (new CCPoint(s.Width / 2, s.Height - 80));
            }

            CCMenuItemImage item1 = new CCMenuItemImage(TestResource.s_pPathB1, TestResource.s_pPathB2, backCallback);
            CCMenuItemImage item2 = new CCMenuItemImage(TestResource.s_pPathR1, TestResource.s_pPathR2, restartCallback);
            CCMenuItemImage item3 = new CCMenuItemImage(TestResource.s_pPathF1, TestResource.s_pPathF2, nextCallback);

            CCMenu menu = new CCMenu(item1, item2, item3);

            menu.Position = (new CCPoint(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);
        }
Example #7
0
        public override void OnEnter()
        {
            base.OnEnter();

            CCSize s = Layer.VisibleBoundsWorldspace.Size;

            CCLabelTtf label = new CCLabelTtf(title(), "arial", 40);
            label.AnchorPoint = new CCPoint (0.5f, 0.5f);
            AddChild(label, 1);
            label.Position = (new CCPoint(s.Width / 2, s.Height - 50));

            CCMenuItemImage item1 = new CCMenuItemImage(s_pPathB1, s_pPathB2, backCallback);
            CCMenuItemImage item2 = new CCMenuItemImage(s_pPathR1, s_pPathR2, restartCallback);
            CCMenuItemImage item3 = new CCMenuItemImage(s_pPathF1, s_pPathF2, nextCallback);

            CCMenu menu = new CCMenu(item1, item2, item3);

            float padding = 10.0f;
            float halfRestartWidth = item2.ContentSize.Width / 2.0f;

            menu.Position = (new CCPoint(0, 0));

            // Anchor point of menu items is 0.5, 0.5 by default
            item1.Position = (new CCPoint(s.Width / 2 - item1.ContentSize.Width / 2.0f - halfRestartWidth - padding, item2.ContentSize.Height + padding));
            item2.Position = (new CCPoint(s.Width / 2, item2.ContentSize.Height + padding));
            item3.Position = (new CCPoint(s.Width / 2 + item3.ContentSize.Width / 2.0f + halfRestartWidth + padding, item2.ContentSize.Height + padding));

            AddChild(menu, TestScene.MENU_LEVEL);
        }
Example #8
0
        private bool InitOrientationTest ()
        {
            bool bRet = false;
            do
            {

                CCSize s = Layer.VisibleBoundsWorldspace.Size;

                CCLabelTtf label = new CCLabelTtf(title(), "Arial", 26);
                AddChild(label, 1);
                label.Position = new CCPoint(s.Width / 2, s.Height - 50);

                string sSubtitle = subtitle();
                if (sSubtitle.Length > 0)
                {
                    CCLabelTtf l = new CCLabelTtf(sSubtitle, "Arial", 16);
                    AddChild(l, 1);
                    l.Position = new CCPoint(s.Width / 2, s.Height - 80);
                }

                CCMenuItemImage item1 = new CCMenuItemImage(TestResource.s_pPathB1, TestResource.s_pPathB2,  BackCallback);
                CCMenuItemImage item2 = new CCMenuItemImage(TestResource.s_pPathR1, TestResource.s_pPathR2,  RestartCallback);
                CCMenuItemImage item3 = new CCMenuItemImage(TestResource.s_pPathF1, TestResource.s_pPathF2,  NextCallback);

                CCMenu menu = new CCMenu(item1, item2, item3);
                menu.Position = new CCPoint();
                item1.Position = new CCPoint(s.Width / 2 - 100, 30);
                item2.Position = new CCPoint(s.Width / 2, 30);
                item3.Position = new CCPoint(s.Width / 2 + 100, 30);

                bRet = true;
            } while (false);

            return bRet;
        }
Example #9
0
        protected override void AddedToScene ()
        {
            base.AddedToScene ();

            Scene.SceneResolutionPolicy = CCSceneResolutionPolicy.ShowAll;

            var scoreLabel = new CCLabelTtf (scoreMessage, "arial", 22) {
                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,
                Dimensions = ContentSize
            };

            AddChild (scoreLabel);

            var playAgainLabel = new CCLabelTtf ("Tap to Play Again", "arial", 22) {
                Position = VisibleBoundsWorldspace.Size.Center,
                Color = new CCColor3B (CCColor4B.Green),
                HorizontalAlignment = CCTextAlignment.Center,
                VerticalAlignment = CCVerticalTextAlignment.Center,
                AnchorPoint = CCPoint.AnchorMiddle,
                Dimensions = ContentSize
            };

            AddChild (playAgainLabel);

            AddMonkey ();
        }
Example #10
0
        public override void OnEnter()
        {
            base.OnEnter();

            CCSize s = Layer.VisibleBoundsWorldspace.Size;

            CCLabelTtf label = new CCLabelTtf(title(), "arial", 24);

            AddChild(label);
            label.Position = new CCPoint(s.Width / 2, s.Height - 50);

            string subTitle = m_pNotificationLayer.subtitle();

            if (subTitle != null)
            {
                CCLabelTtf l = new CCLabelTtf(subTitle, subtitle(), 16);
                AddChild(l, 1);
                l.Position = new CCPoint(s.Width / 2, s.Height - 80);
            }

            CCMenuItemImage item1 = new CCMenuItemImage("Images/b1.png", "Images/b2.png", backCallback);
            CCMenuItemImage item2 = new CCMenuItemImage("Images/r1.png", "Images/r2.png", restartCallback);
            CCMenuItemImage item3 = new CCMenuItemImage("Images/f1.png", "Images/f2.png", nextCallback);

            CCMenu menu = new CCMenu(item1, item2, item3);

            menu.Position  = new CCPoint(0, 0);
            item1.Position = new CCPoint(s.Width / 2 - 100, 30);
            item2.Position = new CCPoint(s.Width / 2, 30);
            item3.Position = new CCPoint(s.Width / 2 + 100, 30);

            AddChild(menu, 1);
        }
 public void InitializeLabel(string initialText)
 {
     label = CCLabelFontHelper.GetFont(initialText);
     label.Position = new CCPoint(Window.WindowSizeInPixels.Width / 2, Window.WindowSizeInPixels.Height - (Window.WindowSizeInPixels.Height / 8));
     // add the label as a child to this Layer
     AddChild(label); // --> TOP
 }
Example #12
0
        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 CCLabelTtf ("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);

            // New code:
            touchListener = new CCEventListenerTouchAllAtOnce ();
            touchListener.OnTouchesMoved = HandleTouchesMoved;
            AddEventListener (touchListener, this);
        }
Example #13
0
        public override void OnEnter()
        {
            base.OnEnter();

            CCSize s = Layer.VisibleBoundsWorldspace.Size;

            CCLabelTtf label = new CCLabelTtf(title(), "arial", 32);
            AddChild(label);
            label.Position = (new CCPoint(s.Width / 2, s.Height - 50));

            string subTitle = subtitle();
            if (!string.IsNullOrEmpty(subTitle))
            {
                CCLabelTtf l = new CCLabelTtf(subTitle, "arial", 16);
                AddChild(l, 1);
                l.Position = new CCPoint(s.Width / 2, s.Height - 80);
            }

            CCMenuItemImage item1 = new CCMenuItemImage("Images/b1", "Images/b2", backCallback);
            CCMenuItemImage item2 = new CCMenuItemImage("Images/r1", "Images/r2", restartCallback);
            CCMenuItemImage item3 = new CCMenuItemImage("Images/f1", "Images/f2", nextCallback);

            CCMenu menu = new CCMenu(item1, item2, item3);
            menu.Position = new CCPoint(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);
        }
Example #14
0
		public virtual void setSceneTitleLabel(CCLabelTtf var)   
		{ 
			if (m_pSceneTitleLabel != var) 
			{ 
				m_pSceneTitleLabel = var; 
			} 
		}
Example #15
0
		public static CCLabelTtf PCLLabel(string message)
		{
			var label = new CCLabelTtf(message, "MarkerFelt", 22);
			label.Color = CCColor3B.White;
			label.Position = CCDrawManager.VisibleSize.Center;
			return label;
		}
        public RenderTextureZbuffer()
        {
            label = new CCLabelTtf("vertexZ = 50", "Marker Felt", 32);
            AddChild(label);

            label2 = new CCLabelTtf("vertexZ = 0", "Marker Felt", 32);
            AddChild(label2);

            label3 = new CCLabelTtf("vertexZ = -50", "Marker Felt", 32);
            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;
        }
Example #17
0
		public GameOverLayer (int score)
		{

			var touchListener = new CCEventListenerTouchAllAtOnce();
			touchListener.OnTouchesEnded = (touches, ccevent) => CCDirector.SharedDirector.ReplaceScene (GameLayer.Scene);

			EventDispatcher.AddEventListener(touchListener, this);

			string scoreMessage = String.Format ("Game Over. You collected {0} bananas!", score);
       
            var scoreLabel = new CCLabelTtf (scoreMessage, "MarkerFelt", 22) {
				Position = new CCPoint( CCDirector.SharedDirector.WinSize.Center.X,  CCDirector.SharedDirector.WinSize.Center.Y + 50),
                Color = new CCColor3B (CCColor4B.Yellow),
				HorizontalAlignment = CCTextAlignment.Center,
				VerticalAlignment = CCVerticalTextAlignment.Center,
				Dimensions = ContentSize
			};

			AddChild (scoreLabel);

            var playAgainLabel = new CCLabelTtf ("Tap to Play Again", "MarkerFelt", 22) {
				Position = CCDirector.SharedDirector.WinSize.Center,
                Color = new CCColor3B (CCColor4B.Green),
				HorizontalAlignment = CCTextAlignment.Center,
				VerticalAlignment = CCVerticalTextAlignment.Center,
				Dimensions = ContentSize
			};

			AddChild (playAgainLabel);

            Color = new CCColor3B (CCColor4B.Black);
			Opacity = 255;

		}
Example #18
0
 private void AddHpLabel() {
     _hpLabel = new CCLabelTtf("HP", "kongtext", 8) {
         Color = CCColor3B.White,
         AnchorPoint = CCPoint.AnchorMiddleBottom,
         Position = new CCPoint(Settings.ScreenWidth/2, BarHeight*0.25f)
     };
     AddChild(_hpLabel);
 }
Example #19
0
 public TTFFontInit()
 {
     font = new CCLabelTtf();
     font.FontName = "MarkerFelt";
     font.FontSize = 38;
     font.Text = ("It is working!");
     AddChild(font);
 }
Example #20
0
        private void AddLevelLabel() {
            _levelLabel = new CCLabelTtf("LVL", "kongtext", 12) {
                Color = CCColor3B.White,
                AnchorPoint = CCPoint.AnchorMiddleBottom,
                Position = new CCPoint(Settings.ScreenWidth/2, BarHeight)
            };

            AddChild(_levelLabel);
        }
Example #21
0
 public override void OnEnter()
 {
     base.OnEnter();
     CCSize size = Layer.VisibleBoundsWorldspace.Size;
     CCLabelTtf label = new CCLabelTtf("cocos2d", "arial", 64);
     label.Position = size.Center;
     label.AnchorPoint = CCPoint.AnchorMiddle;
     AddChild(label);
 }
Example #22
0
        private void AddGoldLabel() {
            _goldLabel = new CCLabelTtf("Gold:", "kongtext", 10) {
                Color = CCColor3B.White,
                AnchorPoint = CCPoint.AnchorLowerLeft,
                Position = new CCPoint(Settings.ScreenWidth/2 + BarWidth/5, BarHeight)
            };

            AddChild(_goldLabel);
        }
Example #23
0
        public Bug624Layer2()
        {
            CCSize size = Layer.VisibleBoundsWorldspace.Size;
            CCLabelTtf label = new CCLabelTtf("Layer2", "MarkerFelt", 36);

            label.Position = new CCPoint(size.Width / 2, size.Height / 2);
            AddChild(label);
            Schedule(switchLayer, 5.0f);

        }
		protected override void AddedToScene()
		{
			base.AddedToScene();

			//Init Game Elements
			_player1Score = 0;
			_player2Score = 0;


			//get screen size
			_screenSize = Window.WindowSizeInPixels; //CCDirector::sharedDirector()->getWinSize();

			//1. add court image
			GameSprite court = new GameSprite("court"); // CCSprite::create("court.png");
			court.SetPosition(new CCPoint(_screenSize.Width * 0.5f, _screenSize.Height * 0.5f)); //->setPosition(ccp());

			AddChild(court);

			//2. add players
			_player1 = new GameSprite("mallet"); //GameSprite::gameSpriteWithFile("mallet.png");
			_player1.SetPosition(new CCPoint(_screenSize.Width * 0.5f, _player1.RotationX * 2f));

			AddChild(_player1, 0, kPlayer1Tag);

			_player2 = new GameSprite("mallet");
			_player2.SetPosition(new CCPoint(_screenSize.Width * 0.5f, _screenSize.Height - _player1.RotationX * 2));
			AddChild(_player2, 0, kPlayer2Tag);

			_players = new GameSprite[] { _player1, _player2 };// CCArray::create(_player1, _player2, NULL);

			//3. add puck
			_ball = new GameSprite("puck");
			_ball.SetPosition(new CCPoint(_screenSize.Width * 0.5f, _screenSize.Height * 0.5f - 2f * _ball.RotationX));
			AddChild(_ball);

			//4. add score display
			_player1ScoreLabel = new CCLabelTtf("0", "MarkerFelt", 22);
			_player1ScoreLabel.Position = new CCPoint(_screenSize.Width - 60f, _screenSize.Height * 0.5f - 80f);
			_player1ScoreLabel.Rotation = 90;
			AddChild(_player1ScoreLabel);

			_player2ScoreLabel = new CCLabelTtf("0", "MarkerFelt", 22);
			_player2ScoreLabel.Position = new CCPoint(_screenSize.Width - 60f, _screenSize.Height * 0.5f + 80f);
			_player2ScoreLabel.Rotation = 90;
			AddChild(_player2ScoreLabel);

			//listen for touches
			CCEventListenerTouchAllAtOnce tListener = new CCEventListenerTouchAllAtOnce();
			tListener.OnTouchesBegan = TouchesBegan;
			tListener.OnTouchesEnded = TouchesEnded;
			tListener.OnTouchesMoved = TouchesMoved;
			AddEventListener(tListener, this);

			Schedule(Update);
		}
Example #25
0
        public LabelTTFMultiline()
        {
            // CCLabelBMFont
			center = new CCLabelTtf("word wrap \"testing\" (bla0) bla1 'bla2' [bla3] (bla4) {bla5} {bla6} [bla7] (bla8) [bla9] 'bla0' \"bla1\"",
                "Paint Boy", 32, 
                CCSize.Zero, 
                CCTextAlignment.Center);
            

            AddChild(center);
        }
Example #26
0
        protected override void AddedToScene() {
            base.AddedToScene();

            _label = new CCLabelTtf("Chat", "kongtext", 8) {
                Color = CCColor3B.White,
                Position = new CCPoint(0, 0)
            };

            AddChild(_label);

            Schedule(Update);
        }
Example #27
0
        public MultiTouchTestLayer()
        {
			var listener = new CCEventListenerTouchAllAtOnce();
			listener.OnTouchesBegan = onTouchesBegan;
			listener.OnTouchesMoved = onTouchesMoved;
			listener.OnTouchesEnded = onTouchesEnded;

			AddEventListener(listener);   

			title = new CCLabelTtf("Please touch the screen!", "", 24);
			AddChild(title);
		}
        public IntroLayer()
        {
            // create and initialize a Label
            label = new CCLabelTtf("Hello CocosSharp", "MarkerFelt", 22);
            label.AnchorPoint = CCPoint.AnchorMiddle;

            // add the label as a child to this Layer
            AddChild(label);

            // setup our color for the background
            Color = new CCColor3B(CCColor4B.Blue);
            Opacity = 255;
        }
        protected override void AddedToScene ()
        {
            base.AddedToScene ();

            var label = new CCLabelTtf("Tap Screen to Go Bananas!", "arial", 22) {
                Position = VisibleBoundsWorldspace.Center,
                Color = CCColor3B.Green,
                HorizontalAlignment = CCTextAlignment.Center,
                VerticalAlignment = CCVerticalTextAlignment.Center,
                AnchorPoint = CCPoint.AnchorMiddle
            };

            AddChild (label);
        }
Example #30
0
 public override void OnEnter()
 {
     base.OnEnter();
     float x, y;
     CCSize size = Layer.VisibleBoundsWorldspace.Size;
     x = size.Width;
     y = size.Height;
     //CCMutableArray *array = [UIFont familyNames];
     //for( CCString *s in array )
     //	NSLog( s );
     CCLabelTtf label = new CCLabelTtf("cocos2d", "arial", 64);
     label.Position = new CCPoint(x / 2, y / 2);
     AddChild(label);
 }
Example #31
0
        public virtual bool onTextFieldInsertText(CCTextFieldTTF pSender, string text, int nLen)
        {
            // if insert enter, treat as default to detach with ime
            if ("\n" == text)
            {
                return(false);
            }

            // if the textfield's char count more than m_nCharLimit, doesn't insert text anymore.
            if (pSender.Text.Length >= m_nCharLimit)
            {
                return(true);
            }

            // create a insert text sprite and do some action
            CCLabelTtf label = new CCLabelTtf(text, TextInputTestScene.FONT_NAME, TextInputTestScene.FONT_SIZE);

            this.AddChild(label);
            CCColor3B color = new CCColor3B {
                R = 226, G = 121, B = 7
            };

            label.Color = color;

            // move the sprite from top to position
            CCPoint endPos = pSender.Position;

            if (pSender.Text.Length > 0)
            {
                endPos.X += pSender.ContentSize.Width / 2;
            }
            CCSize  inputTextSize = label.ContentSize;
            CCPoint beginPos      = new CCPoint(endPos.X, Layer.VisibleBoundsWorldspace.Size.Height - inputTextSize.Height * 2);

            float duration = 0.5f;

            label.Position = beginPos;
            label.Scale    = 8;

            CCAction seq = new CCSequence(
                new CCSpawn(
                    new CCMoveTo(duration, endPos),
                    new CCScaleTo(duration, 1),
                    new CCFadeOut(duration)),
                new CCCallFuncN(callbackRemoveNodeWhenDidAction));

            label.RunAction(seq);
            return(false);
        }
Example #32
0
        public LabelTTFA8Test()
        {
			var layer = new CCLayerColor(new CCColor4B(128, 128, 128, 255));
            AddChild(layer, -10);

            // CCLabelBMFont
			label1 = new CCLabelTtf("Testing A8 Format", "MarkerFelt", 38);
            AddChild(label1);
            label1.Color = CCColor3B.Red;


			var fadeOut = new CCFadeOut  (2);
			var fadeIn = new CCFadeIn  (2);
			label1.RepeatForever(fadeIn, fadeOut);
        }
Example #33
0
        public IntroLayer()
        {
            // create and initialize a Label
            var label = new CCLabelTtf("Hello Cocos2D-XNA", "MarkerFelt", 22);

            // position the label on the center of the screen
            label.Position = Director.WindowSizeInPixels.Center;

            // add the label as a child to this Layer
            AddChild(label);

            // setup our color for the background
            Color = CCColor3B.Blue;
            Opacity = 255;
        }
Example #34
0
        public CCControlSwitchSprite(CCSprite maskSprite, CCSprite onSprite, CCSprite offSprite, CCSprite thumbSprite,
                                     CCLabelTtf onLabel, CCLabelTtf 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();
        }
Example #35
0
        public virtual bool onTextFieldDeleteBackward(CCTextFieldTTF pSender, string delText, int nLen)
        {
            // create a delete text sprite and do some action
            CCLabelTtf label = new CCLabelTtf(delText, TextInputTestScene.FONT_NAME, TextInputTestScene.FONT_SIZE);

            this.AddChild(label);

            // move the sprite to fly out
            CCPoint beginPos      = pSender.Position;
            CCSize  textfieldSize = pSender.ContentSize;
            CCSize  labelSize     = label.ContentSize;

            beginPos.X += (textfieldSize.Width - labelSize.Width) / 2.0f;

            int      RAND_MAX = 32767;
            CCRandom rand     = new CCRandom();

            CCSize  winSize        = Layer.VisibleBoundsWorldspace.Size;
            CCPoint endPos         = new CCPoint(-winSize.Width / 4.0f, winSize.Height * (0.5f + (float)CCRandom.Next() / (2.0f * RAND_MAX)));
            float   duration       = 1;
            float   rotateDuration = 0.2f;
            int     repeatTime     = 5;

            label.Position = beginPos;

            CCAction seq = new CCSequence(
                new CCSpawn(
                    new CCMoveTo(duration, endPos),
                    new CCRepeat(
                        new CCRotateBy(rotateDuration, (CCRandom.Next() % 2 > 0) ? 360 : -360),
                        (uint)repeatTime),
                    new CCFadeOut(duration)),
                new CCCallFuncN(callbackRemoveNodeWhenDidAction));

            label.RunAction(seq);
            return(false);
        }
Example #36
0
 public CCMenuItemLabelTTF(CCLabelTtf labelTTF, Action <object> target = null) : base(target)
 {
     LabelTTF = labelTTF;
 }