本文整理汇总了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);
}
示例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);
}
示例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);
}