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


C# CCSprite.RunActions方法代码示例

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


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

示例1: OnEnter

        public override void OnEnter()
        {
            base.OnEnter();

            CCSprite child = new CCSprite(s_pPathGrossini);
			child.Position = Layer.VisibleBoundsWorldspace.Size.Center;
            AddChild(child, 1);

            //Sum of all action's duration is 1.5 second.
            child.RunAction(new CCRotateBy (1.5f, 90));
			child.RunActions (new CCDelayTime (1.4f), new CCFadeOut (1.1f));

            //After 1.5 second, self will be removed.
			RunActions (new CCDelayTime (1.4f), new CCCallFunc ((removeThis)));
        }
开发者ID:KevinHeyer,项目名称:CocosSharp,代码行数:15,代码来源:CrashTest.cs

示例2: AddBanana

		CCSprite AddBanana ()
		{
			var banana = new CCSprite ("Banana");

			double rnd = new Random ().NextDouble ();
			double randomX = (rnd > 0) 
				? rnd * CCDirector.SharedDirector.WinSize.Width - banana.ContentSize.Width / 2 
				: banana.ContentSize.Width / 2;
	
			banana.Position = new CCPoint ((float)randomX, CCDirector.SharedDirector.WinSize.Height - banana.ContentSize.Height / 2);

			AddChild (banana);

			var moveBanana = new CCMoveTo (5.0f, new CCPoint (banana.Position.X, 0));

			banana.RunActions (moveBanana, moveBananaComplete);

			banana.RepeatForever (rotateBanana);

			return banana;
		}
开发者ID:KerwinMa,项目名称:CocosSharp,代码行数:21,代码来源:GameLayer.cs

示例3: AddBanana

        CCSprite AddBanana()
        {
            var spriteSheet = new CCSpriteSheet ("animations/monkey.plist");
            var banana = new CCSprite (spriteSheet.Frames.Find ((x) => x.TextureFilename.StartsWith ("Banana")));

            var p = GetRandomPosition (banana.ContentSize);
            banana.Position = p;
            banana.Scale = 0.5f;

            AddChild (banana);

            var moveBanana = new CCMoveTo (5.0f, new CCPoint (banana.Position.X, 0));
            banana.RunActions (moveBanana, moveBananaComplete);
            banana.RepeatForever (rotateBanana);

            return banana;
        }
开发者ID:jonathanzuniga,项目名称:GoneBananas,代码行数:17,代码来源:GameLayer.cs

示例4: AddMonster

        private void AddMonster(float time)
        {
            var selectedMonster = new Random().Next() % _monsters.Count;

            var monster = _monsters[selectedMonster];
            var m = monster.Movement;

            //!IMPORTANT -- Every Sprite in Screen must be an new CCSprite! Each Sprite can only be one time on screen
            var spriteMonster = new CCSprite(monster.MonsterSprite);
            spriteMonster.Scale = _appScale;
            spriteMonster.Tag = monster.Tag;

            //BLOCK 1 - Determine where to spawn the monster along the Y axis
            var winSize = Window.WindowSizeInPixels;
            var minX = (spriteMonster.ContentSize.Width / 2);
            var maxX = winSize.Width - spriteMonster.ContentSize.Width / 2;
            var rangeX = maxX - minX;
            var actualY = (new Random().Next() % rangeX) + minX;

            //BLOCK 2 - Determine speed of the monster
            var minDuration = monster.MinVelocity;
            var maxDuration = monster.MaxVelocity;
            var rangeDuration = maxDuration - minDuration;
            var actualDuration = (new Random().Next() % rangeDuration) + minDuration;

            if(m == 1)
            {
                spriteMonster.Position = new CCPoint(actualY, winSize.Height + spriteMonster.ContentSize.Height/2);
                AddChild(spriteMonster);

                var actionMove = new CCMoveTo(actualDuration, new CCPoint(actualY, -spriteMonster.ContentSize.Height/2));
                var actionMoveComplete = new CCCallFuncN (node =>
                    {
                        _monstersOnScreen.Remove(node);
                        node.RemoveFromParent();

                        _lives--;
                        var index = _hearths.Count - 1;
                        RemoveChild(_hearths[index]);
                        _hearths.RemoveAt(index);
                        if(_lives == 0)
                        {
                            Window.DefaultDirector.ReplaceScene(GameStartLayer.GameStartLayerScene(Window));
                        }
                    });

                spriteMonster.RunActions(actionMove, actionMoveComplete);
                _monstersOnScreen.Add(spriteMonster);
            }
            else if(m == 2)
            {
                spriteMonster.Position = new CCPoint(actualY, winSize.Height + spriteMonster.ContentSize.Height/2);
                AddChild(spriteMonster);

                var actionMoveComplete = new CCCallFuncN (node =>
                    {
                        _monstersOnScreen.Remove(node);
                        node.RemoveFromParent();

                        _lives--;
                        var index = _hearths.Count - 1;
                        RemoveChild(_hearths[index]);
                        _hearths.RemoveAt(index);
                        if(_lives == 0)
                        {
                            Window.DefaultDirector.ReplaceScene(GameStartLayer.GameStartLayerScene(Window));
                        }
                    });

                var bezierList = new List<CCFiniteTimeAction>();
                var bezier = new CCBezierConfig();
                var splitDuration = actualDuration / 6.0f;
                CCBezierTo bezierAction;

                for(int i = 0; i < 6; i++)
                {
                    if(i % 2 == 0)
                    {
                        bezier.ControlPoint1 = new CCPoint(actualY + 100, winSize.Height - (100 + (i * 200)));
                        bezier.ControlPoint2 = new CCPoint(actualY + 100, winSize.Height - (100 + (i * 200)));
                        bezier.EndPosition = new CCPoint(actualY, winSize.Height - (200 + (i * 200)));
                        bezierAction = new CCBezierTo(splitDuration, bezier);
                    }
                    else
                    {
                        bezier.ControlPoint1 = new CCPoint(actualY - 100, winSize.Height - (100 + (i * 200)));
                        bezier.ControlPoint2 = new CCPoint(actualY - 100, winSize.Height - (100 + (i * 200)));
                        bezier.EndPosition = new CCPoint(actualY, winSize.Height - (200 + (i * 200)));
                        bezierAction = new CCBezierTo(splitDuration, bezier);
                    }

                    bezierList.Add(bezierAction);
                }

                bezierList.Add(actionMoveComplete);

                var seq = new CCSequence(bezierList.ToArray());
                spriteMonster.RunAction(seq);

                _monstersOnScreen.Add(spriteMonster);
//.........这里部分代码省略.........
开发者ID:jonathanzuniga,项目名称:MonsterSmashing,代码行数:101,代码来源:MonsterRun.cs


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