Пример #1
0
        public IntroLayer()
            : base(CCColor4B.Gray)
        {
            titleLabel = new CCLabel("CocosJuce", "fonts/Roboto-Light-72.fnt");
            frequencyLabel = new CCLabel("", "fonts/Roboto-Light-72.fnt");

            onOffSwitchSpriteFrameCache = CCSpriteFrameCache.SharedSpriteFrameCache;
            onOffSwitchSpriteFrameCache.AddSpriteFrames("images/onoffswitch.plist");

            switchOnSprite = new CCSprite("switch_on.png");
            switchOffSprite = new CCSprite("switch_off.png");
            onOffSwitch = new CCMenuItemToggle(SwitchToggle, new CCMenuItem[]
                                                         {
                                                             new CCMenuItemImage(switchOffSprite) { },
                                                             new CCMenuItemImage(switchOnSprite) { },
                                                         });

            menu = new CCMenu(onOffSwitch);

            freqKnobSpriteFrameCache = CCSpriteFrameCache.SharedSpriteFrameCache;
            freqKnobSpriteFrameCache.AddSpriteFrames("images/frequencyknob.plist");

            frequencyKnob = new CCSprite("frequencyknob00.png");

            AddChild(titleLabel);
            AddChild(menu);
            AddChild(frequencyLabel);
            AddChild(frequencyKnob);
        }
        public override void OnEnter ()
        {
            base.OnEnter ();

            var origin = Layer.VisibleBoundsWorldspace.Size;

            var label1 = new CCLabel(string.Empty, "debuguncompressed", 0, CCLabelFormat.SpriteFont);

            var texture = label1.TextureAtlas != null ? label1.TextureAtlas.Texture : null;

            if (texture != null) {
                spriteFontNode = new CCSprite (texture);
                spriteFontNode.Scale = 2;
            }
            else
            {
                spriteFontNode = new CCLabel("Texture can not be loaded", "arial", 24, CCLabelFormat.SpriteFont);
            }
            //spriteFontNode.Color = CCColor3B.Magenta;
            spriteFontNode.Position = origin.Center;


            AddChild (spriteFontNode);

            var itemUncompressed = new CCMenuItemLabel(new CCLabel("Uncompressed", "fonts/arial", 24, CCLabelFormat.SpriteFont));
            var itemCompressed = new CCMenuItemLabel(new CCLabel("Compressed", "fonts/arial", 24, CCLabelFormat.SpriteFont));
            itemUncompressed.AnchorPoint = CCPoint.AnchorMiddleLeft;
            itemCompressed.AnchorPoint = CCPoint.AnchorMiddleLeft;
            var mi1 = new CCMenuItemToggle(OnToggle, itemUncompressed, itemCompressed);
            var menu = new CCMenu(mi1);

            AddChild(menu);
            menu.Position = VisibleBoundsWorldspace.Left();
        }
        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);
        }
Пример #4
0
        public LayerGradient()
        {
            gradientLayer = new CCLayerGradient(new CCColor4B(255, 0, 0, 255), new CCColor4B(0, 255, 0, 255), new CCPoint(0.9f, 0.9f));

            AddChild(gradientLayer, 0, kTagLayer);

			// Register Touch Event
			var touchListener = new CCEventListenerTouchAllAtOnce();
			touchListener.OnTouchesMoved = onTouchesMoved;
			AddEventListener(touchListener);

            CCLabelTtf label1 = new CCLabelTtf("Compressed Interpolation: Enabled", "arial", 26);
            CCLabelTtf label2 = new CCLabelTtf("Compressed Interpolation: Disabled", "arial", 26);
            CCMenuItemLabelTTF item1 = new CCMenuItemLabelTTF(label1);
            CCMenuItemLabelTTF item2 = new CCMenuItemLabelTTF(label2);
            CCMenuItemToggle item = new CCMenuItemToggle((toggleItem), item1, item2);

            menu = new CCMenu(item);
            AddChild(menu);
        }
Пример #5
0
        public LayerGradient()
        {
            //gradientLayer = new CCLayerGradient(new CCColor4B(255, 0, 0, 255), new CCColor4B(0, 255, 0, 255), new CCPoint(0.9f, 0.9f));

            gradientLayer = new CCLayerGradient(CCColor4B.Red, CCColor4B.Green);
            gradientLayer.UpdateColor();
            //gradientLayer.StartOpacity = 127;
            //gradientLayer.EndOpacity = 127;
            AddChild(gradientLayer, 0, kTagLayer);

			// Register Touch Event
			var touchListener = new CCEventListenerTouchAllAtOnce();
			touchListener.OnTouchesMoved = onTouchesMoved;
			AddEventListener(touchListener);

            var label1 = new CCLabel("Compressed Interpolation: Enabled", "arial", 26, CCLabelFormat.SpriteFont);
            var label2 = new CCLabel("Compressed Interpolation: Disabled", "arial", 26, CCLabelFormat.SpriteFont);
            var item1 = new CCMenuItemLabel(label1);
            var item2 = new CCMenuItemLabel(label2);
            var item = new CCMenuItemToggle((toggleItem), item1, item2);

            menu = new CCMenu(item);
            AddChild(menu);
        }
Пример #6
0
		public ParticleDemo()
        {

            toggleParticleMovMenuItem = new CCMenuItemToggle(ToggleCallback,
                new CCMenuItemFont("Free Movement"),
                new CCMenuItemFont("Relative Movement"),
                new CCMenuItemFont("Grouped Movement"));

            particleMenu = new CCMenu(toggleParticleMovMenuItem);
            AddChild(particleMenu, 100);

            particleCounter = new CCLabelAtlas("0000", "Images/fps_Images", 16, 64, '.');
            AddChild(particleCounter, 100, ParticleTestScene.TagLabelAtlas);

            Background = new CCSprite(TestResource.s_back3);
            AddChild(Background, 5);

			// Add event listeners

			var listener = new CCEventListenerTouchAllAtOnce();
			listener.OnTouchesBegan = OnTouchesBegan;
			listener.OnTouchesMoved = OnTouchesMoved;
			listener.OnTouchesEnded = OnTouchesEnded;

			AddEventListener(listener);

			coloredBackground = new CCLayerColor(new CCColor4B(127, 127, 127, 255));
			AddChild(coloredBackground, 4);
        }
        public 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);
        }
Пример #8
0
        public MenuLayer4()
        {
			CCMenuItemFont.FontSize = 18;
			CCMenuItemFont.FontName = "arial";

            CCMenuItemFont title1 = new CCMenuItemFont("Sound");
            title1.Enabled = false;

			CCMenuItemFont.FontSize = 34;
            
            CCMenuItemToggle item1 = new CCMenuItemToggle(this.menuCallback,
                new CCMenuItemFont("On"),
                new CCMenuItemFont("Off"));

			CCMenuItemFont.FontSize = 18;

			CCMenuItemFont title2 = new CCMenuItemFont("Music");
            title2.Enabled = false;

			CCMenuItemFont.FontSize = 34;
            CCMenuItemToggle item2 = new CCMenuItemToggle(this.menuCallback,
                new CCMenuItemFont("On"),
				new CCMenuItemFont("Off"));

			CCMenuItemFont.FontSize = 18;
            CCMenuItemFont title3 = new CCMenuItemFont("Quality");
            title3.Enabled = false;

			CCMenuItemFont.FontSize = 34;
            CCMenuItemToggle item3 = new CCMenuItemToggle(this.menuCallback,
                new CCMenuItemFont("High"),
                new CCMenuItemFont("Low"));
                
				CCMenuItemFont.FontSize = 18;
            CCMenuItemFont title4 = new CCMenuItemFont("Orientation");
            title4.Enabled = false;

				CCMenuItemFont.FontSize = 34;

            CCMenuItemToggle item4 = new CCMenuItemToggle(this.menuCallback,
                new CCMenuItemFont("Off"));

            item4.AddToggleMenuItems(new CCMenuItemFont ("33%"), new CCMenuItemFont ("66%"), new CCMenuItemFont ("100%"));

            // you can change the one of the items by doing this
            item4.SelectedIndex = 2;

            CCLabelBMFont label = new CCLabelBMFont("go back", "fonts/bitmapFontTest3.fnt");
            CCMenuItemLabelBMFont back = new CCMenuItemLabelBMFont(label, this.backCallback);

            CCMenu menu = new CCMenu(
                          title1, title2,
                          item1, item2,
                          title3, title4,
                          item3, item4,
				back) { Tag = 36 }; // 9 items.

            menu.AlignItemsInColumns(2, 2, 2, 2, 1);

            AddChild(menu);
        }