Example #1
0
        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;
        }
Example #2
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 #3
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);
        }
        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);
        }
Example #5
0
		public NodeToWorld3D()
		{
			//
			// This code tests that nodeToParent works OK:
			//  - It tests different anchor Points
			//  - It tests different children anchor points

			parent = new CCNode();
			parent.AnchorPoint = new CCPoint(0.5f, 0.5f);
			AddChild(parent);

			back = new CCSprite(TestResource.s_back3);
			parent.AddChild(back, -10);
			back.AnchorPoint = CCPoint.Zero;


			var item = new CCMenuItemImage(TestResource.s_PlayNormal, TestResource.s_PlaySelect);
			menu = new CCMenu(item);
			menu.AlignItemsVertically();

			back.AddChild(menu);

			item.RepeatForever(CocosNodeTestStaticLibrary.nodeRotate);

			back.RepeatForever(CocosNodeTestStaticLibrary.nodeMove, CocosNodeTestStaticLibrary.nodeMove.Reverse());

			parent.RunAction (CocosNodeTestStaticLibrary.nodeOrbit);
		}
Example #6
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 #7
0
        public override void OnEnter()
        {
            base.OnEnter();

            var s = Layer.VisibleBoundsWorldspace.Size;

			CCMenuItemFont.FontSize = 24;
			CCMenuItemFont.FontName = "arial";

            var pMainItem = new CCMenuItemFont("Back", toMainLayer);
            pMainItem.Position = new CCPoint(s.Width - 50, 25);
            var pMenu = new CCMenu(pMainItem);
            pMenu.Position = new CCPoint(0, 0);

            if (m_bControlMenuVisible)
            {
                var item1 = new CCMenuItemImage("Images/b1", "Images/b2", backCallback);
                var item2 = new CCMenuItemImage("Images/r1", "Images/r2", restartCallback);
                var item3 = new CCMenuItemImage("Images/f1", "Images/f2", nextCallback);
                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);

                pMenu.AddChild(item1, PerformanceTestScene.kItemTagBasic);
                pMenu.AddChild(item2, PerformanceTestScene.kItemTagBasic);
                pMenu.AddChild(item3, PerformanceTestScene.kItemTagBasic);
            }
            AddChild(pMenu);
        }
Example #8
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);
        }
Example #9
0
		public HighScoreLayer (int score): base()
		{
			currentScore = score;


			var batchnode = GetChildByTag ((int)Tags.SpriteManager) as CCSpriteBatchNode;
			var title = new CCSprite(batchnode.Texture,new CCRect(608,192,225,57));
            title.Position=new CCPoint(160,240);
			batchnode.AddChild (title);



			var button1 = new CCMenuItemImage("Images/playAgainButton", "Images/playAgainButton",
                new Action<object>(delegate(object o) {
			 	 Director.ReplaceScene(new CCTransitionFade(.5f, GameLayer.Scene, new CCColor3B(255,255,255)));
                }));
			var button2 = new CCMenuItemImage("Images/changePlayerButton", "Images/changePlayerButton", new Action<object>(delegate (object sender) {
                // do nothing
			}));
			var menu = new CCMenu(button1,button2);
            menu.Position=new CCPoint(160,58);
			menu.AlignItemsVertically(9);

			AddChild (menu);
			

		}
Example #10
0
        public CCControlScene()
		{  
			// Get the screensize
			CCSize screensize = Layer.VisibleBoundsWorldspace.Size;

			var pBackItem = new CCMenuItemFont("Back", toExtensionsMainLayer);
			pBackItem.Position = new CCPoint(screensize.Width - 50, 25);
			var pBackMenu = new CCMenu(pBackItem);
			pBackMenu.Position =  CCPoint.Zero;
			AddChild(pBackMenu, 10);

			// Add the generated background
			var background = new CCSprite("extensions/background");
			background.Position = new CCPoint(screensize.Width / 2, screensize.Height / 2);
			AddChild(background);
    
			// Add the ribbon
			var ribbon = new CCScale9SpriteFile("extensions/ribbon", new CCRect(1, 1, 48, 55));
			ribbon.ContentSize = new CCSize(screensize.Width, 57);
			ribbon.Position = new CCPoint(screensize.Width / 2.0f, screensize.Height - ribbon.ContentSize.Height / 2.0f);
			AddChild(ribbon);
    
			// Add the title
			setSceneTitleLabel(new CCLabelTtf(" ", "Arial", 12));
			m_pSceneTitleLabel.Position = new CCPoint(screensize.Width / 2, screensize.Height - m_pSceneTitleLabel.ContentSize.Height / 2 - 5);
			AddChild(m_pSceneTitleLabel, 1);

            // Add the subtitle
            setSceneSubtitleLabel(new CCLabelTtf(" ", "Arial", 12));
		    m_pSceneSubtitleLabel.Position = new CCPoint(screensize.Width / 2,
		                                                 screensize.Height - m_pSceneTitleLabel.ContentSize.Height -
		                                                 m_pSceneSubtitleLabel.ContentSize.Height / 2 - 10);
            AddChild(m_pSceneSubtitleLabel, 1);
    
			// Add the menu
			var item1 = new CCMenuItemImage("Images/b1", "Images/b2", previousCallback);
			var item2 = new CCMenuItemImage("Images/r1", "Images/r2", restartCallback);
			var item3 = new CCMenuItemImage("Images/f1", "Images/f2", nextCallback);
    
			var menu = new CCMenu(item1, item3, item2);
			menu.Position = CCPoint.Zero;
			item1.Position = new CCPoint(screensize.Width / 2 - 100, 37);
			item2.Position = new CCPoint(screensize.Width / 2, 35);
			item3.Position = new CCPoint(screensize.Width / 2 + 100, 37);
    
			AddChild(menu, 1);
		}
Example #11
0
        protected override void AddedToScene()
        {
            base.AddedToScene();

            var label = new CCLabelBMFont("Enable AtlasItem", "fonts/bitmapFontTest3.fnt");
            var item1 = new CCMenuItemLabelBMFont(label, this.menuCallback2);

            CCMenuItemFont.FontSize = 28;
            CCMenuItemFont.FontName = "arial";

            var item2 = new CCMenuItemFont("--- Go Back ---", this.menuCallback);

            // 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 item3 = new CCMenuItemImage(spriteNormal, spriteSelected, spriteDisabled, this.menuCallback3);
            m_disabledItem = item3;
            m_disabledItem.Enabled = false;

            var menu = new CCMenu(item1, item2, item3);
            menu.Position = new CCPoint(0, 0);

            var s = Layer.VisibleBoundsWorldspace.Size;

            item1.Position = new CCPoint(s.Width / 2 - 150, s.Height / 2);
            item2.Position = new CCPoint(s.Width / 2 - 200, s.Height / 2);
            item3.Position = new CCPoint(s.Width / 2, s.Height / 2 - 100);

            var jump = new CCJumpBy (3, new CCPoint(400, 0), 50, 4);
            item2.RepeatForever(jump, jump.Reverse());

            var spin1 = new CCRotateBy (3, 360);

            item1.RepeatForever(spin1);
            item2.RepeatForever(spin1);
            item3.RepeatForever(spin1);

            AddChild(menu);
        }
Example #12
0
        public bool initWithEntryID(int entryId)
        {
            CCSize s = CCDirector.SharedDirector.WinSize;

            m_entryID = entryId;

			// Register Touch Event
			var touchListener = new CCEventListenerTouchOneByOne();
			touchListener.IsSwallowTouches = true;

			touchListener.OnTouchBegan = onTouchBegan;
			touchListener.OnTouchMoved = onTouchMoved;

			EventDispatcher.AddEventListener(touchListener, this);

            Box2DView view = Box2DView.viewWithEntryID(entryId);
            AddChild(view, 0, kTagBox2DNode);
            view.Scale = 10;
            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", 28);
            //#endif
            AddChild(label, 1);
            label.Position = new CCPoint(s.Width / 2, s.Height - 50);

            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);

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

            Scene.SceneResolutionPolicy = CCSceneResolutionPolicy.ShowAll;

            var winSize = Window.WindowSizeInPixels;
            var backgroundImage = new CCSprite("WoodRetroApple_iPad_HomeScreen.jpg");
            backgroundImage.Position = new CCPoint(winSize.Width / 2, winSize.Height / 2);
            _appScale = winSize.Height / backgroundImage.ContentSize.Height;
            backgroundImage.ScaleX = _appScale;
            backgroundImage.ScaleY = _appScale;
            AddChild(backgroundImage, -2);

            var monsters = new CCSprite("backgroundMonsters2.png");
            monsters.Position = new CCPoint(winSize.Width / 2, winSize.Height / 2);
            monsters.ScaleX = _appScale;
            monsters.ScaleY = _appScale;
            AddChild(monsters, -1);

            var logo = new CCSprite("MonsterSmashing.png");
            logo.Position = new CCPoint(winSize.Width/2, winSize.Height * 0.7f);
            logo.Scale = _appScale;
            AddChild(logo);

            var startGameButtonImage = new CCMenuItemImage("play.png", "playSelected.png", obj =>
                {
                    var transition = new CCTransitionFlipAngular(0.5f, MonsterRun.GameScene(Window), CCTransitionOrientation.DownOver);
                    Window.DefaultDirector.ReplaceScene(transition);
                });
            startGameButtonImage.Scale = _appScale;

            _soundOn = new CCMenuItemImage("soundOn.png", "soundOnSelected.png");
            _soundOff = new CCMenuItemImage("soundOff.png", "soundOffSelected.png");
            var toggleItem = new CCMenuItemToggle(obj => {}, _soundOn, _soundOff);
            toggleItem.Scale = _appScale;

            var menu = new CCMenu(startGameButtonImage, toggleItem);
            menu.Position = new CCPoint(winSize.Width * 0.5f, winSize.Height * 0.4f);
            menu.AlignItemsVertically(15);
            AddChild(menu);
        }
Example #14
0
        public override void OnEnter()
        {
            base.OnEnter();

            var visibleRect = VisibleBoundsWorldspace;

            // add title and subtitle
            var label = new CCLabel(Title(), "Arial", 32, CCLabelFormat.SpriteFont);
            AddChild(label, 9999);
            label.Position = new CCPoint(visibleRect.Center.X, visibleRect.Top().Y - 30);

            string strSubtitle = Subtitle();
            if (!string.IsNullOrEmpty(strSubtitle))
            {
                var l = new CCLabel(strSubtitle, "Thonburi", 16, CCLabelFormat.SpriteFont);
                AddChild(l, 9999);
                l.Position = new CCPoint(visibleRect.Center.X, visibleRect.Top().Y - 60);
            }

            // add menu
            // CC_CALLBACK_1 == std::bind( function_ptr, instance, std::placeholders::_1, ...)
            var item1 = new CCMenuItemImage(TestResource.s_pPathB1, TestResource.s_pPathB2,
                                            BackCallback);
            var item2 = new CCMenuItemImage(TestResource.s_pPathR1, TestResource.s_pPathR2,
                                            RestartCallback);
            var item3 = new CCMenuItemImage(TestResource.s_pPathF1, TestResource.s_pPathF2,
                                            NextCallback);

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

            menu.Position = CCPoint.Zero;
            item1.Position = new CCPoint(visibleRect.Center.X - item2.ContentSize.Width * 2,
                visibleRect.Bottom().Y + item2.ContentSize.Height / 2);
            item2.Position = new CCPoint(visibleRect.Center.X,
                visibleRect.Bottom().Y + item2.ContentSize.Height / 2);
            item3.Position = new CCPoint(visibleRect.Center.X + item2.ContentSize.Width * 2,
                visibleRect.Bottom().Y + item2.ContentSize.Height / 2);

            AddChild(menu, 9999);
        }
Example #15
0
        private void InitBug458Layer()
        {
            // ask director the the window size
            CCSize size = Layer.VisibleBoundsWorldspace.Size;

            QuestionContainerSprite question = new QuestionContainerSprite();
            QuestionContainerSprite question2 = new QuestionContainerSprite();

            //		[question setContentSize:CGSizeMake(50,50)];
            //		[question2 setContentSize:CGSizeMake(50,50)];

            CCMenuItemImage sprite = new CCMenuItemImage(question2, question, selectAnswer);

            //CCLayerColor layer = new CCLayerColor(new CCColor4B(0, 0, 255, 255), 100, 100);
            //CCLayerColor layer2 = new CCLayerColor(new CCColor4B(255, 0, 0, 255), 100, 100);
            //CCMenuItemImage sprite2 = new CCMenuItemImage(layer, layer2, this, selectAnswer);
            CCMenu menu = new CCMenu(sprite, null);
            menu.AlignItemsVertically(100);
            menu.Position = new CCPoint(size.Width / 2, size.Height / 2);

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

        }
Example #16
0
        public MainMenuLayer()
        {
            //CCSimpleAudioEngine.SharedEngine.PreloadBackgroundMusic("music/menu");
            //CCSimpleAudioEngine.SharedEngine.PreloadBackgroundMusic("music/level1");

            CCSimpleAudioEngine.SharedEngine.PlayBackgroundMusic("music/menu", true);
            //CCSimpleAudioEngine.SharedEngine.PlayEffect("DigitalStream");

            Color = CCColor3B.Black;
            Opacity = 255;

            //TouchEnabled = true;

            //CCEventListenerTouchAllAtOnce eTouch = new CCEventListenerTouchAllAtOnce();
            //eTouch.OnTouchesBegan = TouchesBegan;
            //eTouch.OnTouchesBegan = TouchesBegan;
            //eTouch.OnTouchesBegan = TouchesBegan;
            //eTouch.OnTouchesBegan = TouchesBegan;
            //EventDispatcher.AddEventListener(eTouch);

            //CCMenuItemFont tt2 = new CCMenuItemFont("Caracola de chan");
            //tt2.Color = new CCColor3B(Microsoft.Xna.Framework.Color.Blue);
            //tt.SetPosition(200, 300);

            CCMenuItem tt2 = new CCMenuItemImage("menu/nuevo", "menu/nuevo_off", Seleccionado);
            tt2.Scale = 0.7f;

            CCMenuItem tt3 = new CCMenuItemImage("menu/salir", "menu/salir_off", Salir);
            tt3.Scale = 0.7f;

            CCMenu t = new CCMenu(new CCMenuItem[] { tt2 });
            t.Color = CCColor3B.Black;
            t.SetPosition(Director.WindowSizeInPixels.Width / 2, Director.WindowSizeInPixels.Height / 2);

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

			layerInstance = this;

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



			//INITIAL VARIABLES.... (D O N T    E D I T )

			// enable touches
#if XBOX || OUYA
            TouchEnabled = false;
            GamePadEnabled = true;
#else
			//TouchEnabled = true;

			CCEventListenerTouchAllAtOnce tListener = new CCEventListenerTouchAllAtOnce();

			tListener.OnTouchesBegan = TouchesBegan;
			//tListener.OnTouchesCancelled = TouchesCancelled;
			tListener.OnTouchesEnded = TouchesEnded;
			tListener.OnTouchesMoved = TouchesMoved;

			AddEventListener(tListener, this);

#endif


			// enable accelerometer
			//AccelerometerEnabled = false;

#if iPHONE || iOS
			IS_IPAD = MonoTouch.UIKit.UIDevice.CurrentDevice.UserInterfaceIdiom 
				== MonoTouch.UIKit.UIUserInterfaceIdiom.Pad;

			IS_RETINA = MonoTouch.UIKit.UIScreen.MainScreen.Bounds.Height 
				* MonoTouch.UIKit.UIScreen.MainScreen.Scale >= 1136;
#endif
#if WINDOWS || MACOS || MONOMAC || LINUX || OUYA || XBOX
			IS_IPAD = true;
			IS_RETINA = true;
#endif

			IS_IPHONE = !IS_IPAD;

			// ask director for the window size
			screenWidth = (int)screenSize.Width;
			screenHeight = (int)screenSize.Height;

			throwInProgress = false; //is a throw currently in progress, as in, is a ninja in midair (mostly used to prevent tossing two ninjas, one right after another)
			areWeInTheStartingPosition = true;  //is the world back at 0 on the X axis (if yes, then we can put a ninja in the sling)

			throwCount = 0;
			dotTotalOnOddNumberedTurn = 0;
			dotTotalOnEvenNumberedTurn = 0;

			currentLevel = GameData.SharedData.Level;  // use currentLevel =  0 for testing new shapes, will call [self buildLevelWithAllShapes];

			pointTotalThisRound = 0;
			pointsToPassLevel = GameData.SharedData.PointsToPassLevel;
			bonusPerExtraNinja = GameData.SharedData.BonusPerExtraNinja;

			CCLog.Log(string.Format("The level is {0}, you need {1} to move up a level", currentLevel, pointsToPassLevel));

			//PREFERENCE VARIABLES....

			openWithMenuInsteadOfGame = false; // start with the menu opening the game

			continuePanningScreenOnFingerRelease = true; // if the screen panning is midway between either the sling or targets, when you release your finger the screen will continue panning the last direction it moved (jumpy on iPhone if set to NO)
			reverseHowFingerPansScreen = false; //switch to yes to reverse. 
			topRightTouchEnablesDebugMode = true;  //SET TO NO IN FINAL BUILD
			useImagesForPointScoreLabels = true; //IF NO, means you use Marker Felt text for scores

			//set up background art

			backgroundLayerClouds = new CCSprite(GameData.SharedData.BackgroundCloudsFileName);  // will return the background clouds file for a particular level
			AddChild(backgroundLayerClouds, Constants.DepthClouds);

			backgroundLayerHills = new CCSprite(GameData.SharedData.BackgroundHillsFileName);  // will return the background hills file for a particular level
			AddChild(backgroundLayerHills, Constants.DepthHills);
			backgroundLayerHills.ScaleX = 1.05f;

			slingShotFront = new CCSprite("slingshot_front");
			AddChild(slingShotFront, Constants.DepthSlingShotFront);

			strapFront = new CCSprite("strap");
			AddChild(strapFront, Constants.DepthStrapFront);


			strapBack = new CCSprite("strapBack");
			AddChild(strapBack, Constants.DepthStrapBack);

			strapEmpty = new CCSprite("strapEmpty");
			AddChild(strapEmpty, Constants.DepthStrapBack);


			strapBack.Visible = false;  //visible only when stretching
			strapFront.Visible = false; //visible only when stretching



			//setup positions and variables for iPad devices or iPhones

			if (IS_IPAD)
			{
				areWeOnTheIPad = true;

				//vars 

				maxStretchOfSlingShot = 75; //best to leave as is, since this value ties in closely to the image size of strap.png. (should be 1/4 the size of the source image)
				multipyThrowPower = 1; // fine tune how powerful the sling shot is. Range is probably best between .5 to 1.5, currently for the iPad 1.0 is good

				worldMaxHorizontalShift = -(screenWidth);  // This determines how far the user can slide left or right to see the entire board. Always a negative number. 
				maxScaleDownValue = 1.0f; //dont change
				scaleAmount = 0; // increment to change the scale of the entire world when panning  
				initialPanAmount = 30; //how fast the screen pan starts
				extraAmountOnPanBack = 10; // I like a faster pan back. Adding a bit more
				adjustY = 0; // best to leave at 0 for iPad (moves the world down when panning)

				//background stuff

				backgroundLayerClouds.Position = new CCPoint(screenWidth, screenHeight / 2);
				backgroundLayerHills.Position = new CCPoint(screenWidth, screenHeight / 2);

				if (!IS_RETINA)
				{


					//non retina adjustment


				}
				else
				{

					//retina adjustment

					backgroundLayerClouds.Scale = 2.0f;
					backgroundLayerHills.Scale = 2.0f;
				}


				menuStartPosition = new CCPoint(130, screenSize.Height - 24);
				currentScoreLabelStartPosition = new CCPoint(200, screenSize.Height - 60);
				highScoreLabelStartPosition = new CCPoint(200, screenSize.Height - 80);

				fontSizeForScore = 22;

				//ground plane and platform

				groundPlaneStartPosition = new CCPoint(screenWidth, 50);
				platformStartPosition = new CCPoint(340, 190);

				//sling shot
				slingShotCenterPosition = new CCPoint(370, 255);

				slingShotFront.Position = new CCPoint(374, 240);
				strapFront.Position = new CCPoint(slingShotCenterPosition.X, slingShotCenterPosition.Y);
				strapBack.Position = new CCPoint(slingShotCenterPosition.X + 33, slingShotCenterPosition.Y - 10);
				strapEmpty.Position = new CCPoint(378, 235);

				//ninja

				ninjaStartPosition1 = new CCPoint(380, 250);
				ninjaStartPosition2 = new CCPoint(300, 155);
				ninjaStartPosition3 = new CCPoint(260, 155);
				ninjaStartPosition4 = new CCPoint(200, 120);
				ninjaStartPosition5 = new CCPoint(160, 120);

			}

			else if (IS_IPHONE)
			{
				//CCLOG (@"this is an iphone");

				areWeOnTheIPad = false;

				//vars 
				maxStretchOfSlingShot = 75; //best to leave as is, since this value ties in closely to the image size of strap.png. (should be 1/4 the size of the source image)
				multipyThrowPower = 1.0f; // fine tune how powerful the sling shot is. Range is probably best between .5 to 1.5, and a little goes a long way

				worldMaxHorizontalShift = -(screenWidth); // This determines how far the user can slide left or right to see the entire board. Always a negative number
				maxScaleDownValue = 0.65f; //range should probably be between 0.75 and 1.0;
				scaleAmount = .01f; // increment to change the scale of the entire world when panning
				adjustY = -34;

				initialPanAmount = 20; //how fast the screen pan starts
				extraAmountOnPanBack = 0; // best to leave at 0 on iPhone

				//background stuff



				if (!IS_RETINA)
				{

					//non retina adjustment

					backgroundLayerClouds.Position = new CCPoint(screenWidth, 192);
					backgroundLayerClouds.Scale = .7f;
					backgroundLayerHills.Position = new CCPoint(screenWidth, 245);
					backgroundLayerHills.Scale = .7f;

				}
				else
				{

					//retina adjustment

					backgroundLayerClouds.Position = new CCPoint(screenWidth, 192);
					backgroundLayerClouds.Scale = 1.7f;
					backgroundLayerHills.Position = new CCPoint(screenWidth, 265);
					backgroundLayerHills.Scale = 1.7f;
				}



				menuStartPosition = new CCPoint(70, screenSize.Height - 17);
				currentScoreLabelStartPosition = new CCPoint(140, screenSize.Height - 50); //score label
				highScoreLabelStartPosition = new CCPoint(140, screenSize.Height - 70);
				fontSizeForScore = 18;

				//ground plane and platform

				groundPlaneStartPosition = new CCPoint(screenWidth, -25);
				platformStartPosition = new CCPoint(130, 120);

				//sling shot

				slingShotCenterPosition = new CCPoint(160, 185);
				slingShotFront.Position = new CCPoint(164, 170);
				strapFront.Position = new CCPoint(slingShotCenterPosition.X, slingShotCenterPosition.Y);
				strapBack.Position = new CCPoint(slingShotCenterPosition.X + 33, slingShotCenterPosition.Y - 10);
				strapEmpty.Position = new CCPoint(168, 163);

				//ninja

				ninjaStartPosition1 = new CCPoint(170, 175);
				ninjaStartPosition2 = new CCPoint(110, 82);
				ninjaStartPosition3 = new CCPoint(65, 82);
				ninjaStartPosition4 = new CCPoint(90, 65);
				ninjaStartPosition5 = new CCPoint(43, 65);



			}

			SetUpParticleSystemSun();

			CCMenuItemImage button1 = new CCMenuItemImage("gameMenu", "gameMenu", ShowMenu);

			MenuButton = new CCMenu(button1);
			MenuButton.Position = menuStartPosition;
			AddChild(MenuButton, Constants.DepthScore);



			// assign CCPoints to keep track of the starting positions of objects that move relative to the entire layer.

			hillsLayerStartPosition = backgroundLayerHills.Position;
			cloudLayerStartPosition = backgroundLayerClouds.Position;

			// Define the gravity vector.

			yAxisGravity = -9.81f;

			b2Vec2 gravity = b2Vec2.Zero;
			gravity.Set(0.0f, yAxisGravity);


			// Construct a world object, which will hold and simulate the rigid bodies.
			world = new b2World(gravity);

			world.AllowSleep = false;

			world.SetContinuousPhysics(true);

			//EnableDebugMode();


			// Define the ground body.
			var groundBodyDef = new b2BodyDef();  // Make sure we call 
			groundBodyDef.position.Set(0, 0); // bottom-left corner

			// Call the body factory which allocates memory for the ground body
			// from a pool and creates the ground box shape (also from a pool).
			// The body is also added to the world.
			b2Body groundBody = world.CreateBody(groundBodyDef);

			// Define the ground box shape.
			b2EdgeShape groundBox = new b2EdgeShape();

			int worldMaxWidth = screenWidth * 4; //If you ever want the BOX2D world width to be more than it is then increase this  (currently, this should be plenty of extra space)
			int worldMaxHeight = screenHeight * 3; //If you ever want the BOX2D world height to be more  than it is then increase this (currently, this should be plenty of extra space)

			// bottom
			groundBox.Set(new b2Vec2(-4, 0), new b2Vec2(worldMaxWidth / Constants.PTM_RATIO, 0));
			groundBody.CreateFixture(groundBox, 0);

			// top
			groundBox.Set(new b2Vec2(-4, worldMaxHeight / Constants.PTM_RATIO), new b2Vec2(worldMaxWidth / Constants.PTM_RATIO, worldMaxHeight / Constants.PTM_RATIO));
			groundBody.CreateFixture(groundBox, 0);

			// left
			groundBox.Set(new b2Vec2(-4, worldMaxHeight / Constants.PTM_RATIO), new b2Vec2(-4, 0));
			groundBody.CreateFixture(groundBox, 0);

			// right
			groundBox.Set(new b2Vec2(worldMaxWidth / Constants.PTM_RATIO, worldMaxHeight / Constants.PTM_RATIO), new b2Vec2(worldMaxWidth / Constants.PTM_RATIO, 0));
			groundBody.CreateFixture(groundBox, 0);

			//Contact listener 
			contactListener = new ContactListener();
			world.SetContactListener(contactListener);

			//Set up the ground plane

			theGroundPlane = new GroundPlane(world, groundPlaneStartPosition, GameData.SharedData.GroundPlaneFileName);
			AddChild(theGroundPlane, Constants.DepthFloor);


			//Set up the starting platform

			thePlatform = new StartPlatform(world, platformStartPosition, "platform");
			AddChild(thePlatform, Constants.DepthPlatform);

			//Set up ninjas

			ninjaBeingThrown = 1; //always starts at 1 (first ninja, then second ninja, and so on) 
			ninjasToTossThisLevel = GameData.SharedData.NumberOfNinjasToTossThisLevel;  //total number of ninjas to toss for this level



			ninja1 = new Ninja(world, ninjaStartPosition1, @"ninja");
			AddChild(ninja1, Constants.DepthNinjas);

			currentBodyNode = ninja1;

			currentBodyNode.SpriteInSlingState();

			if (ninjasToTossThisLevel >= 2)
			{

				ninja2 = new Ninja(world, ninjaStartPosition2, @"ninjaRed");
				AddChild(ninja2, Constants.DepthNinjas);
				ninja2.SpriteInStandingState();

			}
			if (ninjasToTossThisLevel >= 3)
			{

				ninja3 = new Ninja(world, ninjaStartPosition3, @"ninjaBlue");
				AddChild(ninja3, Constants.DepthNinjas);
				ninja3.SpriteInStandingState();
			}
			if (ninjasToTossThisLevel >= 4)
			{

				ninja4 = new Ninja(world, ninjaStartPosition4, @"ninjaBrown");
				AddChild(ninja4, Constants.DepthNinjas);
				ninja4.SpriteInStandingState();
			}
			if (ninjasToTossThisLevel >= 5)
			{

				ninja5 = new Ninja(world, ninjaStartPosition5, @"ninjaGreen");
				AddChild(ninja5, Constants.DepthNinjas);
				ninja5.SpriteInStandingState();
			}

			//Build the Stack. 

			stack = new TheStack(world);
			AddChild(stack, Constants.DepthStack);


			//give the stack a moment to drop, then switches every pieces to static (locks it into position, until the first slingshot)...
			ScheduleOnce(SwitchAllStackObjectsToStatic, 1.0f);

			currentScoreLabel = new CCLabelTtf(String.Format("{0}: Needed", pointsToPassLevel), "MarkerFelt", fontSizeForScore);
			AddChild(currentScoreLabel, Constants.DepthScore);
			currentScoreLabel.Color = new CCColor3B(255, 255, 255);
			currentScoreLabel.Position = currentScoreLabelStartPosition;
			currentScoreLabel.AnchorPoint = new CCPoint(1, .5f);
			// HighScoreForLevel
			highScoreLabel = new CCLabelTtf(String.Format("High Score: {0}", GameData.SharedData.HighScoreForLevel), "MarkerFelt", fontSizeForScore);
			AddChild(highScoreLabel, Constants.DepthScore);
			highScoreLabel.Color = new CCColor3B(255, 255, 255);

			highScoreLabel.Position = currentScoreLabel.Position - new CCPoint(0, highScoreLabel.ContentSize.Height);// highScoreLabelStartPosition;
			highScoreLabel.AnchorPoint = new CCPoint(1, .5f);
			highScoreLabelStartPosition = highScoreLabel.Position;


			var levelString = string.Format("Level: {0}", currentLevel);
			ShowBoardMessage(levelString);

			CCLog.Log(" ");
			CCLog.Log(" ");
			CCLog.Log(" ");
			CCLog.Log("/////////////////////////////////////////////////////");
			CCLog.Log("/////////////////////////////////////////////////////");
			CCLog.Log(" ");
			CCLog.Log(" ");
			CCLog.Log(" ");
			CCLog.Log("The art and animation in this template is copyright CartoonSmart LLC");
			CCLog.Log("You must make significant changes to the art before submitting your game to the App Store");
			CCLog.Log("Please create your own characters, backgrounds, etc and spend the time to make the game look totally unique");
			CCLog.Log(" ");
			CCLog.Log(" ");
			CCLog.Log(" ");
			CCLog.Log("The Video guide for this template is at https://vimeo.com/cartoonsmart/angryninjasguide  ");
			CCLog.Log(" ");
			CCLog.Log(" ");
			CCLog.Log(" ");
			CCLog.Log("/////////////////////////////////////////////////////");
			CCLog.Log("/////////////////////////////////////////////////////");
			CCLog.Log(" ");
			CCLog.Log(" ");




			GameSounds.SharedGameSounds.IntroTag();

			if (GameData.SharedData.Level == 1)
			{

				GameSounds.SharedGameSounds.PlayBackgroundMusic(AmbientFXSounds.Frogs);

			}
			else
			{

				GameSounds.SharedGameSounds.PlayBackgroundMusic(AmbientFXSounds.Insects);
			}

			if (GameData.SharedData.FirstRunEver && openWithMenuInsteadOfGame)
			{
				CCLog.Log("First run ever");
				Schedule(ShowMenuFromSelector, 2f);
				GameData.SharedData.FirstRunEver = false;
			}

			// Always do this last.
			this.Schedule(Tick);
		}
Example #18
0
 void ShowIngameMenu()
 {
     CCMenuItem tt2 = new CCMenuItemImage("menu/nuevo", "menu/nuevo_off", SelectedIngameMenu);
     tt2.Scale = 0.7f;
 }
        public override void OnEnter()
        {
            base.OnEnter();

            CCSize s = Layer.VisibleBoundsWorldspace.Size;

            var label = new CCLabel(title(), "arial", 32, CCLabelFormat.SpriteFont);
            AddChild(label, 0, kTagLabel);
            label.Position = new CCPoint(s.Width / 2, s.Height - 50);

            string subTitle = this.subtitle();
            if (subTitle.Length > 0)
            {
                var l = new CCLabel(subTitle, "arial", 16, CCLabelFormat.SpriteFont);
                AddChild(l, 1);
                l.Position = new CCPoint(s.Width / 2, s.Height - 80);
            }

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

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

            menu.Position = CCPoint.Zero;
            item1.Position = new CCPoint(s.Width / 2 - item2.ContentSize.Width * 2, item2.ContentSize.Height / 2);
            item2.Position = new CCPoint(s.Width / 2, item2.ContentSize.Height / 2);
            item3.Position = new CCPoint(s.Width / 2 + item2.ContentSize.Width * 2, item2.ContentSize.Height / 2);

            AddChild(menu, 1);

            var itemMode = new CCMenuItemToggle(modeCallback,
                                                   new CCMenuItemFont("Use High Quality Mode"),
                                                   new CCMenuItemFont("Use Fast Mode")
                );

            var menuMode = new CCMenu(itemMode);
            AddChild(menuMode);

            menuMode.Position = new CCPoint(s.Width / 2, s.Height / 4);
        }
		protected override void AddedToScene()
		{
			base.AddedToScene();

			screenSize = Window.WindowSizeInPixels;

			CCPoint menu1Position;
			CCPoint menu2Position;

			menuBackgroundName = "menu_background";
			//will use "menu_background.png" for non-Retina Phones 
			//will use   "menu_background-hd.png"; for retina phones
			//will use "menu_background-ipad.png";

			//same goes for images below..

			lvlButtonName1 = "levelButton1";
			lvlLockedButtonName1 = "levelButton1_locked";

			lvlButtonName2 = "levelButton2";
			lvlLockedButtonName2 = "levelButton2_locked";

			lvlButtonName3 = "levelButton3";
			lvlLockedButtonName3 = "levelButton3_locked";

			lvlButtonName4 = "levelButton4";
			lvlLockedButtonName4 = "levelButton4_locked";

			lvlButtonName5 = "levelButton5";
			lvlLockedButtonName5 = "levelButton5_locked";

			lvlButtonName6 = "levelButton6";
			lvlLockedButtonName6 = "levelButton6_locked";

			lvlButtonName7 = "levelButton7";
			lvlLockedButtonName7 = "levelButton7_locked";

			lvlButtonName8 = "levelButton8";
			lvlLockedButtonName8 = "levelButton8_locked";

			lvlButtonName9 = "levelButton9";
			lvlLockedButtonName9 = "levelButton9_locked";

			lvlButtonName10 = "levelButton10";
			lvlLockedButtonName10 = "levelButton10_locked";

			voiceButtonName = "voiceFX";
			voiceButtonNameDim = "voiceFX_dim";

			soundButtonName = "soundFX";
			soundButtonNameDim = "soundFX_dim";

			ambientButtonName = "ambientFX";
			ambientButtonNameDim = "ambientFX_dim";


			if (TheLevel.SharedLevel.IS_IPAD)
			{ //iPADs..

				menu1Position = new CCPoint(screenSize.Width / 2, 430);
				menu2Position = new CCPoint(screenSize.Width / 2, 290);

				SoundFXMenuLocation = new CCPoint(240, 170);
				VoiceFXMenuLocation = new CCPoint(480, 170);
				AmbientFXMenuLocation = new CCPoint(750, 170);



				//if( ! CCDirector.SharedDirector.enableRetinaDisplay ) {

				CCLog.Log("must be iPad 1 or 2");

				//change nothing 

				//} else {

				CCLog.Log("retina display is on-must be iPAd 3");

				//change files names for iPad 3 

				menuBackgroundName = "menu_background-ipad";  //will use @"menu_background-ipad-hd"; 

				lvlButtonName1 = "levelButton1-ipad";
				lvlLockedButtonName1 = "levelButton1_locked-ipad";

				lvlButtonName2 = "levelButton2-ipad";
				lvlLockedButtonName2 = "levelButton2_locked-ipad";

				lvlButtonName3 = "levelButton3-ipad";
				lvlLockedButtonName3 = "levelButton3_locked-ipad";

				lvlButtonName4 = "levelButton4-ipad";
				lvlLockedButtonName4 = "levelButton4_locked-ipad";

				lvlButtonName5 = "levelButton5-ipad";
				lvlLockedButtonName5 = "levelButton5_locked-ipad";

				lvlButtonName6 = "levelButton6-ipad";
				lvlLockedButtonName6 = "levelButton6_locked-ipad";

				lvlButtonName7 = "levelButton7-ipad";
				lvlLockedButtonName7 = "levelButton7_locked-ipad";

				lvlButtonName8 = "levelButton8-ipad";
				lvlLockedButtonName8 = "levelButton8_locked-ipad";

				lvlButtonName9 = "levelButton9-ipad";
				lvlLockedButtonName9 = "levelButton9_locked-ipad";

				lvlButtonName10 = "levelButton10-ipad";
				lvlLockedButtonName10 = "levelButton10_locked-ipad";

				voiceButtonName = "voiceFX-ipad";
				voiceButtonNameDim = "voiceFX_dim-ipad";

				soundButtonName = "soundFX-ipad";
				soundButtonNameDim = "soundFX_dim-ipad";

				ambientButtonName = "ambientFX-ipad";
				ambientButtonNameDim = "ambientFX_dim-ipad";
				//}


			}
			else
			{  //IPHONES..



				menu1Position = new CCPoint(screenSize.Width / 2, 185);
				menu2Position = new CCPoint(screenSize.Width / 2, 115);

				SoundFXMenuLocation = new CCPoint(110, 55);
				VoiceFXMenuLocation = new CCPoint(230, 55);
				AmbientFXMenuLocation = new CCPoint(355, 55);

			}

			var theBackground = new CCSprite(menuBackgroundName);
			theBackground.Position = new CCPoint(screenSize.Width / 2, screenSize.Height / 2);
			AddChild(theBackground, 0);

			//TouchEnabled = true;

			CCMenuItem button1;
			CCMenuItem button2;
			CCMenuItem button3;
			CCMenuItem button4;
			CCMenuItem button5;
			CCMenuItem button6;
			CCMenuItem button7;
			CCMenuItem button8;
			CCMenuItem button9;
			CCMenuItem button10;

			button1 = new CCMenuItemImage(lvlButtonName1, lvlButtonName1, GoToFirstLevelSection1);

			if (GameData.SharedData.CanYouGoToTheFirstLevelOfThisSection(2) == false)
			{

				button2 = new CCMenuItemImage(lvlLockedButtonName2, lvlLockedButtonName2, PlayNegativeSound);

			}
			else
			{

				button2 = new CCMenuItemImage(lvlButtonName2, lvlButtonName2, GoToFirstLevelSection2);
			}

			if (GameData.SharedData.CanYouGoToTheFirstLevelOfThisSection(3) == false)
			{

				button3 = new CCMenuItemImage(lvlLockedButtonName3, lvlLockedButtonName3, PlayNegativeSound);

			}
			else
			{

				button3 = new CCMenuItemImage(lvlButtonName3, lvlButtonName3, GoToFirstLevelSection3);
			}

			if (GameData.SharedData.CanYouGoToTheFirstLevelOfThisSection(4) == false)
			{

				button4 = new CCMenuItemImage(lvlLockedButtonName4, lvlLockedButtonName4, PlayNegativeSound);

			}
			else
			{

				button4 = new CCMenuItemImage(lvlButtonName4, lvlButtonName4, GoToFirstLevelSection4);
			}

			if (GameData.SharedData.CanYouGoToTheFirstLevelOfThisSection(5) == false)
			{

				button5 = new CCMenuItemImage(lvlLockedButtonName5, lvlLockedButtonName5, PlayNegativeSound);

			}
			else
			{

				button5 = new CCMenuItemImage(lvlButtonName5, lvlButtonName5, GoToFirstLevelSection5);
			}

			if (GameData.SharedData.CanYouGoToTheFirstLevelOfThisSection(6) == false)
			{

				button6 = new CCMenuItemImage(lvlLockedButtonName6, lvlLockedButtonName6, PlayNegativeSound);

			}
			else
			{

				button6 = new CCMenuItemImage(lvlButtonName6, lvlButtonName6, GoToFirstLevelSection6);
			}

			if (GameData.SharedData.CanYouGoToTheFirstLevelOfThisSection(7) == false)
			{

				button7 = new CCMenuItemImage(lvlLockedButtonName7, lvlLockedButtonName7, PlayNegativeSound);

			}
			else
			{

				button7 = new CCMenuItemImage(lvlButtonName7, lvlButtonName7, GoToFirstLevelSection7);
			}

			if (GameData.SharedData.CanYouGoToTheFirstLevelOfThisSection(8) == false)
			{

				button8 = new CCMenuItemImage(lvlLockedButtonName8, lvlLockedButtonName8, PlayNegativeSound);

			}
			else
			{

				button8 = new CCMenuItemImage(lvlButtonName8, lvlButtonName8, GoToFirstLevelSection8);
			}

			if (GameData.SharedData.CanYouGoToTheFirstLevelOfThisSection(9) == false)
			{

				button9 = new CCMenuItemImage(lvlLockedButtonName9, lvlLockedButtonName9, PlayNegativeSound);

			}
			else
			{

				button9 = new CCMenuItemImage(lvlButtonName9, lvlButtonName9, GoToFirstLevelSection9);
			}

			if (GameData.SharedData.CanYouGoToTheFirstLevelOfThisSection(10) == false)
			{

				button10 = new CCMenuItemImage(lvlLockedButtonName10, lvlLockedButtonName10, PlayNegativeSound);

			}
			else
			{

				button10 = new CCMenuItemImage(lvlButtonName10, lvlButtonName10, GoToFirstLevelSection10);
			}

			CCMenu Menu = new CCMenu(button1, button2, button3, button4, button5);
			Menu.Position = menu1Position;

			Menu.AlignItemsHorizontally(10);
			AddChild(Menu, 1);

			CCMenu Menu2 = new CCMenu(button6, button7, button8, button9, button10);
			Menu2.Position = menu2Position;
			Menu2.AlignItemsHorizontally(10);
			AddChild(Menu2, 1);


			IsSoundFXMenuItemActive = !GameData.SharedData.AreSoundFXMuted;

			IsVoiceFXMenuActive = !GameData.SharedData.AreVoiceFXMuted;

			IsAmbientFXMenuActive = !GameData.SharedData.AreAmbientFXMuted;
		}
Example #21
0
        public override void OnEnter()
        {
            base.OnEnter();

            CCTextureCache.SharedTextureCache.DumpCachedTextureInfo();
            CCSize s = Layer.VisibleBoundsWorldspace.Size;
            CCLabelTtf label = new CCLabelTtf(title(), "arial", 26);
            AddChild(label, 1, (int) (enumTag.kTagLabel));
            label.Position = new CCPoint(s.Width / 2, s.Height - 50);

            string strSubtitle = subtitle();
            if (strSubtitle.Length > 0)
            {
                CCLabelTtf l = new CCLabelTtf(strSubtitle, "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(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);
            CCTextureCache.SharedTextureCache.DumpCachedTextureInfo();
        }
Example #22
0
        public MenuLayer2()
        {
            for (int i = 0; i < 2; i++)
            {
                CCMenuItemImage item1 = new CCMenuItemImage(s_PlayNormal, s_PlaySelect, menuCallback);
                CCMenuItemImage item2 = new CCMenuItemImage(s_HighNormal, s_HighSelect, menuCallbackOpacity);
                CCMenuItemImage item3 = new CCMenuItemImage(s_AboutNormal, s_AboutSelect, menuCallbackAlign);

                item1.ScaleX = 1.5f;
                item2.ScaleX = 0.5f;
                item3.ScaleX = 0.5f;

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

                menu.Tag = (int)kTag.kTagMenu;

                AddChild(menu, 0, 100 + i);

                m_centeredMenu = menu.Position;
            }

            m_alignedH = true;
            alignMenusH();
        }
Example #23
0
        protected override void AddedToScene()
        {
            base.AddedToScene();

            for (int i = 0; i < 2; i++)
            {
                var item1 = new CCMenuItemImage(s_PlayNormal, s_PlaySelect, menuCallback);
                var item2 = new CCMenuItemImage(s_HighNormal, s_HighSelect, menuCallbackOpacity);
                var item3 = new CCMenuItemImage(s_AboutNormal, s_AboutSelect, menuCallbackAlign);

                item1.ScaleX = 1.5f;
                item2.ScaleX = 0.5f;
                item3.ScaleX = 0.5f;

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

                menu.Tag = (int)kTag.kTagMenu;

                AddChild(menu, 0, 100 + i);

                m_centeredMenu = menu.Position;
            }

            m_alignedH = true;
            alignMenusH();
        }
Example #24
0
        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));
        }
Example #25
0
		public SystemFontTest()
		{
			size = Layer.VisibleBoundsWorldspace.Size;

			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 = CCPoint.Zero;
			item1.Position = new CCPoint(size.Width / 2 - item2.ContentSize.Width * 2, item2.ContentSize.Height / 2);
			item2.Position = new CCPoint(size.Width / 2, item2.ContentSize.Height / 2);
			item3.Position = new CCPoint(size.Width / 2 + item2.ContentSize.Width * 2, item2.ContentSize.Height / 2);
			AddChild(menu, 1);

			blockSize = new CCSize(size.Width / 3, 200);

			var leftColor = new CCLayerColor(new CCColor4B(100, 100, 100, 255));
			var centerColor = new CCLayerColor(new CCColor4B(200, 100, 100, 255));
			var rightColor = new CCLayerColor(new CCColor4B(100, 100, 200, 255));

			leftColor.IgnoreAnchorPointForPosition = false;
			centerColor.IgnoreAnchorPointForPosition = false;
			rightColor.IgnoreAnchorPointForPosition = false;

			leftColor.AnchorPoint = CCPoint.AnchorMiddleLeft;
			centerColor.AnchorPoint = CCPoint.AnchorMiddleLeft;
			rightColor.AnchorPoint = CCPoint.AnchorMiddleLeft;

			leftColor.Position = new CCPoint(0, size.Height / 2);
			centerColor.Position = new CCPoint(blockSize.Width, size.Height / 2);
			rightColor.Position = new CCPoint(blockSize.Width * 2, size.Height / 2);

			AddChild(leftColor, -1);
			AddChild(rightColor, -1);
			AddChild(centerColor, -1);

			showFont(SystemFontTestScene.restartAction());
		}
Example #26
0
        public void createResetButton()
        {
            CCMenuItemImage res = new CCMenuItemImage("Images/r1", "Images/r2", reset);

            CCMenu menu = new CCMenu(res);

            CCSize s = Layer.VisibleBoundsWorldspace.Size;

            menu.Position = new CCPoint(s.Width / 2, 30);
            AddChild(menu, -1);
        }
Example #27
0
        public override void OnEnter()
        {
            base.OnEnter();

            CCSize s = Layer.VisibleBoundsWorldspace.Size;

            CCLabelTtf label = new CCLabelTtf(title(), "arial", 28);
            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);

            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 #28
0
        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++;

				}
			}
		}