コード例 #1
0
ファイル: LayerScaleTest.cs プロジェクト: h7ing/CocosSharp
        public override void OnEnter()
        {
            base.OnEnter();

            CCSize s = Layer.VisibleBoundsWorldspace.Size;
            CCLayerColor layer = new CCLayerColor(new CCColor4B(0xFF, 0x00, 0x00, 0x80));

            layer.IgnoreAnchorPointForPosition = false;
            layer.Position = (new CCPoint(s.Width / 2, s.Height / 2));
            AddChild(layer, 1, kTagLayer);
            //
            // Add two labels using BM label class
            // CCLabelBMFont
            var label1 = new CCLabelBMFont("LABEL1", "fonts/konqa32.fnt");
            layer.AddChild(label1);
            label1.Position = new CCPoint(layer.ContentSize.Width / 2, layer.ContentSize.Height * 0.75f);
            var label2 = new CCLabelBMFont("LABEL2", "fonts/konqa32.fnt");
            layer.AddChild(label2);
            label2.Position = new CCPoint(layer.ContentSize.Width / 2, layer.ContentSize.Height * 0.25f);


            //
            // Do the sequence of actions in the bug report
            layer.Visible = false;
			layer.RunActions(hide, scaleTo1, show, delay, scaleTo2, scaleTo3, scaleTo4, scaleTo5);

        }
コード例 #2
0
ファイル: Issue631.cs プロジェクト: KerwinMa/CocosSharp
        public override void OnEnter()
        {
            base.OnEnter();

			var effect = new CCSequence(new CCDelayTime (2.0f), new CCShaky3D(5.0f, new CCGridSize(5, 5), 16, false));

            // cleanup
			RemoveChild(bgNode, true);

            // background
			var layer = new CCLayerColor(new CCColor4B(255, 0, 0, 255));
            AddChild(layer, -10);
			var sprite = new CCSprite("Images/grossini");
            sprite.Position = new CCPoint(50, 80);
            layer.AddChild(sprite, 10);

            // foreground
			var layer2Node = new CCNode ();
			var layer2 = new CCLayerColor(new CCColor4B(0, 255, 0, 255));
			var fog = new CCSprite("Images/Fog");

			var bf = new CCBlendFunc {Source = CCOGLES.GL_SRC_ALPHA, Destination = CCOGLES.GL_ONE_MINUS_SRC_ALPHA};
			fog.BlendFunc = bf;
			layer2.AddChild(fog, 1);
			AddChild(layer2Node, 1);
			layer2Node.AddChild (layer2);

			layer2Node.RepeatForever(effect);
        }
コード例 #3
0
ファイル: Delegate.cs プロジェクト: KevinHeyer/CocosTest
        public override void ApplicationDidFinishLaunching(CCApplication app, CCWindow window)
        {
            app.PreferMultiSampling = false;
            app.ContentRootDirectory = "Content";
            app.ContentSearchPaths.Add("hd");

            CCScene scene = new CCScene(window);
            CCLayerColor layer = new CCLayerColor();
            var label = new CCLabel("Tap Screen To Play!","MarkerFelt-22" , 22)
            {
                Position = layer.VisibleBoundsWorldspace.Center,
                Color = CCColor3B.Black,
                HorizontalAlignment = CCTextAlignment.Center,
                VerticalAlignment = CCVerticalTextAlignment.Center,
                AnchorPoint = CCPoint.AnchorLowerLeft,
                Dimensions = layer.ContentSize
            };
            layer.AddChild(label);
            scene.AddChild(layer);
            window.RunWithScene(scene);
        }
コード例 #4
0
        public override void OnEnter()
        {
            base.OnEnter();

            float x, y;

            CCSize size = Layer.VisibleBoundsWorldspace.Size;
            x = size.Width;
            y = size.Height;

            CCNode blue = new CCLayerColor(new CCColor4B(0, 0, 255, 255));
            CCNode red = new CCLayerColor(new CCColor4B(255, 0, 0, 255));
            CCNode green = new CCLayerColor(new CCColor4B(0, 255, 0, 255));
            CCNode white = new CCLayerColor(new CCColor4B(255, 255, 255, 255));

            blue.Scale = (0.5f);
            blue.Position = (new CCPoint(-x / 4, -y / 4));
            blue.AddChild(new SpriteLayer());

            red.Scale = (0.5f);
            red.Position = (new CCPoint(x / 4, -y / 4));

            green.Scale = (0.5f);
            green.Position = (new CCPoint(-x / 4, y / 4));
            green.AddChild(new TestLayer());

            white.Scale = (0.5f);
            white.Position = (new CCPoint(x / 4, y / 4));

            AddChild(blue, -1);
            AddChild(white);
            AddChild(green);
            AddChild(red);

            blue.RunAction(rot);
            red.RunAction(rot);
            green.RunAction(rot);
            white.RunAction(rot);
        }
コード例 #5
0
		public override void OnEnter ()
		{
			base.OnEnter ();

            CCRect visibleBounds = VisibleBoundsWorldspace;
			var origin = Layer.VisibleBoundsWorldspace.Origin;
			var size = Layer.VisibleBoundsWorldspace.Size;

			var sprite1 = new TouchableSprite ();
			var texture = CCTextureCache.SharedTextureCache.AddImage("Images/CyanSquare.png");
			sprite1.Texture = texture;
			sprite1.Position = origin + new CCPoint (size.Width / 2, size.Height / 2) + new CCPoint (-80, 80);
			AddChild(sprite1, -10);

			var sprite2 = new TouchableSprite ();
			texture = CCTextureCache.SharedTextureCache.AddImage("Images/MagentaSquare.png");
			sprite2.Texture = texture;
			sprite2.Position = origin + new CCPoint (size.Width / 2, size.Height / 2);
			AddChild(sprite2, -20);

			var sprite3 = new TouchableSprite ();
			texture = CCTextureCache.SharedTextureCache.AddImage("Images/YellowSquare.png");
			sprite3.Texture = texture;
			sprite3.Position = CCPoint.Zero;
			sprite2.AddChild(sprite3, -1);

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

			var popup = new CCMenuItemFont("Popup", (sender) =>
				{

                    this.PauseListeners(true);

					var colorLayer = new CCLayerColor(new CCColor4B(0, 0, 255, 100));
					AddChild(colorLayer, 99999);

					var closeItem = new CCMenuItemFont("close", (closeSender) =>
						{
							colorLayer.RemoveFromParent();
                            this.ResumeListeners(true);
				});

                    closeItem.Position = visibleBounds.Center;

					var closeMenu = new CCMenu(closeItem);
					closeMenu.AnchorPoint = CCPoint.AnchorLowerLeft;
					closeMenu.Position = CCPoint.Zero;

					colorLayer.AddChild(closeMenu);
			});

			popup.AnchorPoint = CCPoint.AnchorMiddleRight;
            popup.Position = new CCPoint(visibleBounds.Origin.X + visibleBounds.Size.Width,
                visibleBounds.Origin.Y + visibleBounds.Size.Height / 2);

			var menu = new CCMenu(popup);
			menu.AnchorPoint = CCPoint.AnchorLowerLeft;
			menu.Position = CCPoint.Zero;

			AddChild(menu);

		}
コード例 #6
0
ファイル: LayerTest1.cs プロジェクト: h7ing/CocosSharp
        public override void OnEnter()
        {
            base.OnEnter();

            var s = Layer.VisibleBoundsWorldspace.Size;

            var layer1 = new CCLayerColor(new CCColor4B(192, 0, 0, 255));
            layer1.IsColorCascaded = false;

            layer1.Position = new CCPoint(0, s.Height / 2);

            var sister1 = new CCSprite("Images/grossinis_sister1.png");
            var sister2 = new CCSprite("Images/grossinis_sister2.png");
            var label = new CCLabelBMFont("Test", "fonts/bitmapFontTest.fnt");

            layer1.AddChild(sister1);
            layer1.AddChild(sister2);
            layer1.AddChild(label);
            this.AddChild(layer1, 0, kTagLayer);

            sister1.Position = new CCPoint(s.Width * 1 / 3, 0);
            sister2.Position = new CCPoint(s.Width * 2 / 3, 0);
            label.Position = new CCPoint(s.Width / 2, 0);

			// Define our delay time
			var delay = new CCDelayTime (1);

			layer1.RepeatForever (
                new CCTintTo(6, 255, 0, 255),
                new CCTintTo(6, 255, 255, 255),
				delay
                );

			sister1.RepeatForever (
                new CCTintTo(2, 255, 255, 0),
                new CCTintTo(2, 255, 255, 255),
                new CCTintTo(2, 0, 255, 255),
                new CCTintTo(2, 255, 255, 255),
                new CCTintTo(2, 255, 0, 255),
                new CCTintTo(2, 255, 255, 255),
				delay
                );
        }
コード例 #7
0
ファイル: LayerTest1.cs プロジェクト: h7ing/CocosSharp
        public override void OnEnter()
        {
            base.OnEnter();

            var s = Layer.VisibleBoundsWorldspace.Size;

            var layer1 = new CCLayerColor(new CCColor4B(192, 0, 0, 255));
            layer1.IsColorCascaded = false;

            layer1.Position = new CCPoint(0, s.Height / 2);

			var sister1 = new CCSprite("Images/grossinis_sister1.png");
			var sister2 = new CCSprite("Images/grossinis_sister2.png");
            var label = new CCLabelBMFont("Test", "fonts/bitmapFontTest.fnt");
			// by default a CCLabelBMFont has IsColorModifiedByOpacity on by default if the 
			// texture atlas is PreMultipliedAlpha.  Label as used by Cocos2d-x by default has
			// this set to false.  Maybe this is a bug in Cocos2d-x?
			label.IsColorModifiedByOpacity = false;

            layer1.AddChild(sister1);
            layer1.AddChild(sister2);
            layer1.AddChild(label);
            this.AddChild(layer1, 0, kTagLayer);

            sister1.Position = new CCPoint(s.Width * 1 / 3, 0);
            sister2.Position = new CCPoint(s.Width * 2 / 3, 0);
            label.Position = new CCPoint(s.Width / 2, 0);

			// Define our delay time
			var delay = new CCDelayTime (1);

			layer1.RepeatForever(
				new CCFadeTo(4, 0),
				new CCFadeTo(4, 255),
				delay
			);

			// We only have to define them once.
			var fadeTo11 = new CCFadeTo (2, 0);
			var fadeTo12 = new CCFadeTo (2, 255);

			sister1.RepeatForever(
				fadeTo11,
				fadeTo12,
				fadeTo11,
				fadeTo12,
				delay
			);


            // Enable cascading in scene
            SetEnableRecursiveCascading(this, true);
        }
コード例 #8
0
ファイル: Layertest.cs プロジェクト: netonjm/CocosSharp
        public LayerMultiplexTest()
        {
            for (int i = 0; i < 3; i++)
            {
				CCLayer l = new CCLayerColor(new CCColor4B(0,255,0));
                CCSprite img = null;
                switch (i)
                {
                    case 0:
                        img = new CCSprite("Images/grossini");
                        break;
                    case 1:
                        img = new CCSprite("Images/grossinis_sister1");
                        break;
                    case 2:
                        img = new CCSprite("Images/grossinis_sister2");
                        break;
                }
                img.AnchorPoint = CCPoint.Zero;
                img.Position = CCPoint.Zero;
				l.ContentSize = img.ContentSize;
                l.AddChild(img);
                l.Position = new CCPoint(128f, 128f);
                child.AddLayer(l);
            }
			child.InAction = new CCFadeIn(1);
            AddChild(child);
			Schedule(new Action<float>(AutoMultiplex), 3f);
        }
コード例 #9
0
ファイル: LayerScaleTest.cs プロジェクト: h7ing/CocosSharp
        public override void OnEnter()
        {
            base.OnEnter();

            CCSize s = Layer.VisibleBoundsWorldspace.Size;

            var layer1 = new CCLayerColor(new CCColor4B(0xFF, 0xFF, 0x00, 0x80));
            layer1.IgnoreAnchorPointForPosition = false;
            layer1.Position = (new CCPoint(s.Width / 2, s.Height / 2));
            layer1.ChildClippingMode = CCClipMode.Bounds;
            AddChild(layer1, 1);

            s = layer1.ContentSize;

            m_pInnerLayer = new CCLayerColor(new CCColor4B(0xFF, 0x00, 0x00, 0x80));
            m_pInnerLayer.IgnoreAnchorPointForPosition = false;
            m_pInnerLayer.Position = (new CCPoint(s.Width / 2, s.Height / 2));
            m_pInnerLayer.ChildClippingMode = CCClipMode.Bounds;
            
            layer1.AddChild(m_pInnerLayer, 1);
            
            //
            // Add two labels using BM label class
            // CCLabelBMFont
            CCLabelBMFont label1 = new CCLabelBMFont("LABEL1", "fonts/konqa32.fnt");
            label1.Position = new CCPoint(m_pInnerLayer.ContentSize.Width, m_pInnerLayer.ContentSize.Height * 0.75f);
            m_pInnerLayer.AddChild(label1);
            
            CCLabelBMFont label2 = new CCLabelBMFont("LABEL2", "fonts/konqa32.fnt");
            label2.Position = new CCPoint(0, m_pInnerLayer.ContentSize.Height * 0.25f);
            m_pInnerLayer.AddChild(label2);


            CCScaleTo scaleTo2 = new CCScaleTo(runTime * 0.25f, 3.0f);
            CCScaleTo scaleTo3 = new CCScaleTo(runTime * 0.25f, 1.0f);

            m_pInnerLayer.RepeatForever(scaleTo2, scaleTo3);


            CCFiniteTimeAction seq = new CCRepeatForever(
                new CCSequence(scaleTo2, scaleTo3)
                );

            m_pInnerLayer.RunAction(seq);

            CCSize size = Layer.VisibleBoundsWorldspace.Size;

            var move1 = new CCMoveTo(2, new CCPoint(size.Width / 2, size.Height));
            var move2 = new CCMoveTo(2, new CCPoint(size.Width, size.Height / 2));
            var move3 = new CCMoveTo(2, new CCPoint(size.Width / 2, 0));
            var move4 = new CCMoveTo(2, new CCPoint(0, size.Height / 2));

            layer1.RunAction(new CCRepeatForever(new CCSequence(move1, move2, move3, move4)));
        }