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

            return label;
        }
Exemplo n.º 2
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);
        }
Exemplo n.º 3
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);
        }
Exemplo n.º 4
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);

        }
Exemplo n.º 5
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);
        }
Exemplo n.º 6
0
        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;
        }
Exemplo n.º 7
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;
        }
Exemplo n.º 8
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 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
 }
Exemplo n.º 10
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);
        }
Exemplo n.º 11
0
		public virtual void setSceneTitleLabel(CCLabelTtf var)   
		{ 
			if (m_pSceneTitleLabel != var) 
			{ 
				m_pSceneTitleLabel = var; 
			} 
		}
Exemplo n.º 12
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 ();
        }
Exemplo n.º 13
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);
        }
Exemplo n.º 14
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);
        }
Exemplo n.º 15
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;

		}
Exemplo n.º 16
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);
 }
Exemplo n.º 17
0
 public TTFFontInit()
 {
     font = new CCLabelTtf();
     font.FontName = "MarkerFelt";
     font.FontSize = 38;
     font.Text = ("It is working!");
     AddChild(font);
 }
Exemplo n.º 18
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);
        }
Exemplo n.º 19
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);
        }
Exemplo n.º 20
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);
 }
Exemplo n.º 21
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);

        }
Exemplo n.º 22
0
		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);
		}
Exemplo n.º 23
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);
        }
Exemplo n.º 24
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);
		}
Exemplo n.º 25
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);
        }
Exemplo n.º 26
0
        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;
        }
Exemplo n.º 27
0
        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);
        }
Exemplo n.º 28
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);
 }
Exemplo n.º 29
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);
        }
Exemplo n.º 30
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;
        }