當前位置: 首頁>>代碼示例>>C#>>正文


C# Sprite.CenterOrigin方法代碼示例

本文整理匯總了C#中Microsoft.Xna.Framework.Graphics.Sprite.CenterOrigin方法的典型用法代碼示例。如果您正苦於以下問題:C# Sprite.CenterOrigin方法的具體用法?C# Sprite.CenterOrigin怎麽用?C# Sprite.CenterOrigin使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Microsoft.Xna.Framework.Graphics.Sprite的用法示例。


在下文中一共展示了Sprite.CenterOrigin方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: BackgroundObject

 public BackgroundObject(Texture2D texture, Vector2 position, float rotation, float size, Strategy strategy)
 {
     _sprite = new Sprite(texture);
     Position = position;
     _sprite.Position = position;
     _sprite.Scale = new Vector2(size);
     _sprite.Color = ColorFromSize(size);
     _sprite.CenterOrigin();
     _rotation = rotation;
     _strategy = strategy;
 }
開發者ID:em-mo,項目名稱:sommarhack,代碼行數:11,代碼來源:BackgroundObject.cs

示例2: LevelSelectWindow

        public LevelSelectWindow(WindowHandler windowHandler)
        {
            _windowHandler = windowHandler;
            GraphicsDevice graphicsDevice = _windowHandler.Game.GraphicsDevice;
            _spriteBatch = new SpriteBatch(graphicsDevice);
            _camera = new Camera2D(graphicsDevice);

            _spriteList = new List<Sprite>();

            _background = new Sprite(Game1.contentManager.Load<Texture2D>(@"Images\LevelSelectMan"));
            float windowScaleRatio = graphicsDevice.Viewport.Height / _background.OriginalSize.Y;
            _background.Scale = new Vector2(windowScaleRatio / START_ZOOM);
            _background.CenterOrigin();

            _background.Position = Utils.GetScreenCenter(graphicsDevice);

            _dot = new Sprite(Game1.contentManager.Load<Texture2D>(@"Images\Dot"));
            _dot.CenterOrigin();
            _dot.Color = Color.DarkRed;

            _spriteList.Add(_background);

            Vector2 imageScaledSize = _background.ScaledSize / 2;

            HEART_POSITION = Utils.GetScreenCenter(graphicsDevice);
            KNEE_POSITION = Utils.GetScreenCenter(graphicsDevice);
            NECK_POSITION = Utils.GetScreenCenter(graphicsDevice);
            BRAIN_POSITION = Utils.GetScreenCenter(graphicsDevice);

            HEART_POSITION.X += imageScaledSize.X * -0.005f;
            HEART_POSITION.Y += imageScaledSize.Y * -0.41f;

            KNEE_POSITION.X += imageScaledSize.X * 0.06f;
            KNEE_POSITION.Y += imageScaledSize.Y * 0.43f;

            NECK_POSITION.X += imageScaledSize.X * -0.01f;
            NECK_POSITION.Y += imageScaledSize.Y * -0.65f;

            BRAIN_POSITION.X += imageScaledSize.X * -0.01f;
            BRAIN_POSITION.Y += imageScaledSize.Y * -0.85f;

            BodyPartPositions[BodyPartType.BRAIN] = BRAIN_POSITION;
            BodyPartPositions[BodyPartType.HEART] = HEART_POSITION;
            BodyPartPositions[BodyPartType.NECK] = NECK_POSITION;
            BodyPartPositions[BodyPartType.KNEE] = KNEE_POSITION;
        }
開發者ID:em-mo,項目名稱:sommarhack,代碼行數:46,代碼來源:LevelSelectWindow.cs

示例3: Init

 private void Init()
 {
     InitCellTextures();
     Sprite = new Sprite(_sadTexture);
     Sprite.CenterOrigin();
     Sprite.Scale = new Vector2(0.14f);
     _virusResistance = 5;
     CreateBody();
     Body.LinearDamping = 1;
 }
開發者ID:em-mo,項目名稱:sommarhack,代碼行數:10,代碼來源:GoodCell.cs

示例4: init

 private void init()
 {
     Strategy.Owner = this;
     _virusType = Shared.Random.Next(4);
     _virusType = 0;
     InitCellTextures();
     Sprite = new Sprite(_virusTexture);
     Sprite.CenterOrigin();
     Sprite.Scale = new Vector2(0.08f);
     CreateBody();
     Body.UserData = this;
 }
開發者ID:em-mo,項目名稱:sommarhack,代碼行數:12,代碼來源:Virus.cs


注:本文中的Microsoft.Xna.Framework.Graphics.Sprite.CenterOrigin方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。