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


C# CCSprite.SetPosition方法代码示例

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


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

示例1: IntroLayer

        public IntroLayer()
        {
            CCSize windowSize = CCDirector.SharedDirector.WinSize;

            CCSprite tmp = new CCSprite("goblins");
            tmp.SetPosition(windowSize.Width / 2, windowSize.Height / 2);
            AddChild(tmp);

            String name = @"Content/goblins";
            skeletonNode = new CCSkeletonAnimation(name + ".json", name + ".atlas", 1.0f);

            if (name == "goblins") skeletonNode.setSkin("goblin");

            skeletonNode.NodeToWorldTransform();
            skeletonNode.setSlotsToSetupPose();
            skeletonNode.updateWorldTransform();

            skeletonNode.AddAnimation(0, "walk", true, 4);
            skeletonNode.SetAnimation(0, "walk", true);

            skeletonNode.Start += Start;
            skeletonNode.End += End;
            skeletonNode.Complete += Complete;
            skeletonNode.Event += Event;

            skeletonNode.findSlot("head");

            skeletonNode.SetPosition(windowSize.Width / 2, windowSize.Height / 2);
            AddChild(skeletonNode);
        }
开发者ID:netonjm,项目名称:spine-runtimes,代码行数:30,代码来源:IntroLayer.cs

示例2: BackgroundLayer

        public BackgroundLayer()
        {
            // Load the background image into a sprite
            var backgroundImage = new CCSprite("Images/Background");

            // Get the dimensions of the game window
            var screenSize = CCDirector.SharedDirector.WinSize;

            // Set the position of the background sprite to the center of the screen
            backgroundImage.SetPosition(screenSize.Width / 2, screenSize.Height / 2);

            // Add the background sprite to the layer
            AddChild(backgroundImage, 0);
        }
开发者ID:blueshirt13,项目名称:Cocos2D-XNA-Tutorials,代码行数:14,代码来源:BackgroundLayer.cs

示例3: CreateSprite

        /// <summary>
        /// Creates a new sprite and adds it to the sprite list & screen.
        /// </summary>
        internal void CreateSprite()
        {
            // Get the dimensions of the game window
            var winSize = CCDirector.SharedDirector.WinSize;

            // Get the new number of sprites on the screen and setup an id & image for the sprite (cycles between the 3 available images)
            var numSprites = _sprites.Count + 1;
            var spriteId = "sprite" + numSprites;
            var spriteImage = "Images/Sprite" + ((numSprites % 3) + 1);

            // Create a new instance of the sprite, then setup the position, velocity, & zorder
            var newSprite = new CCSprite(spriteImage);
            newSprite.SetPosition(_rand.Next(150, (int)(winSize.Width - 150f)), _rand.Next(150, (int)(winSize.Height - 150f)));

            // Add the new sprite to the sprite list
            _sprites.Add(spriteId, newSprite);

            // Add the sprite to the layer
            AddChild(newSprite);

            // Set the active sprite to the newly added sprite
            _curSpriteNumber = numSprites - 1;
            SetActiveSprite(true);
        }
开发者ID:blueshirt13,项目名称:Cocos2D-XNA-Tutorials,代码行数:27,代码来源:BasicActionsLayer.cs


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