当前位置: 首页>>代码示例>>C#>>正文


C# CCMenu.RunAction方法代码示例

本文整理汇总了C#中CocosSharp.CCMenu.RunAction方法的典型用法代码示例。如果您正苦于以下问题:C# CCMenu.RunAction方法的具体用法?C# CCMenu.RunAction怎么用?C# CCMenu.RunAction使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CocosSharp.CCMenu的用法示例。


在下文中一共展示了CCMenu.RunAction方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: MenuLayer1

        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));
        }
开发者ID:KerwinMa,项目名称:CocosSharp,代码行数:66,代码来源:MenuLayer1.cs

示例2: AddedToScene

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

				}
			}
		}
开发者ID:KevinHeyer,项目名称:CocosSharp,代码行数:84,代码来源:MenuLayer1.cs


注:本文中的CocosSharp.CCMenu.RunAction方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。