C# 雪碧的鳞片变得可怕

C# 雪碧的鳞片变得可怕,c#,xna,scale,C#,Xna,Scale,我在XNA做了一段时间的太空入侵者游戏。我给入侵者设置了动画,并将其控制在一个阵列中。但是当我调用spriteBatch.Draw和debug时,入侵者精灵得到了巨大的放大!这是我的密码: using System; using System.Collections; using System.Collections.Generic; using System.Linq; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.S

我在XNA做了一段时间的太空入侵者游戏。我给入侵者设置了动画,并将其控制在一个阵列中。但是当我调用spriteBatch.Draw和debug时,入侵者精灵得到了巨大的放大!这是我的密码:

using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Storage;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using Microsoft.Xna.Framework.Net;

namespace SpaceInvaders
{
    class botInvaders
    {

        public botInvaders()
        {

        }

        public static Texture2D g_BotInvaderTex;
        public static Rectangle g_BotInvaderHitBox;
        public static Vector2 g_BotInvaderPos = new Vector2(0, 24);
        public static Vector2 g_BotInvaderOrigin;

        int m_BotInvaderCurrentFrame = 1;
        int m_BotInvaderFrameWidth = 52;
        int m_BotInvaderFrameHeight = 88;

        float m_Timer = 0f;
        float m_Interval = 100;

        public static Rectangle[,] g_BotInvadersRect;
        int m_InvaderRows = 5;
        int m_InvaderCollumns = 10;
        String m_BotInvadersDirection = "RIGHT";
        public static Color InvadersColor = Color.White;

        public void Initialize()
        {

        }

        public void LoadContent(ContentManager Content)
        {
            g_BotInvaderTex = Content.Load<Texture2D>(".\\gameGraphics\\gameSprites\\botInvaders\\normalInvaders\\invaderShip1"); // invaderShip1
            g_BotInvadersRect = new Rectangle[m_InvaderRows, m_InvaderCollumns];
            for (int r = 0; r < m_InvaderRows; r++)
            {
                for (int c = 0; c < m_InvaderCollumns; c++)
                {
                    g_BotInvadersRect[r, c].Width = g_BotInvaderTex.Width;
                    g_BotInvadersRect[r, c].Height = g_BotInvaderTex.Height;
                    g_BotInvadersRect[r, c].X = 70 * c;
                    g_BotInvadersRect[r, c].Y = 70 * r;
                }
            }
        }

        public void Update(GameTime gameTime)
        {
            g_BotInvaderHitBox = new Rectangle(m_BotInvaderCurrentFrame * m_BotInvaderFrameWidth, 0, m_BotInvaderFrameWidth, m_BotInvaderFrameHeight);
            g_BotInvaderOrigin = new Vector2(g_BotInvaderHitBox.X / 2, g_BotInvaderHitBox.Y / 2);

            m_Timer += (float)gameTime.ElapsedGameTime.Milliseconds;

            if (m_Timer > m_Interval)
            {
                m_BotInvaderCurrentFrame++;
                m_Timer = 0f;
            }

            if (m_BotInvaderCurrentFrame == 2)
            {
                m_BotInvaderCurrentFrame = 0;
            }

            g_BotInvaderHitBox = new Rectangle(m_BotInvaderCurrentFrame * m_BotInvaderFrameWidth, 0, m_BotInvaderFrameWidth, m_BotInvaderFrameHeight);
            g_BotInvaderOrigin = new Vector2(g_BotInvaderHitBox.Width / 2, g_BotInvaderHitBox.Height / 2);

            int m_RightSide = 800;
            int m_LeftSide = 0;

            for (int r = 0; r < m_InvaderRows; r++)
            {
                for (int c = 0; c < m_InvaderCollumns; c++)
                {
                    if (m_BotInvadersDirection.Equals("RIGHT"))
                    {
                        g_BotInvadersRect[r, c].X = g_BotInvadersRect[r, c].X + 1;
                    }

                    if (m_BotInvadersDirection.Equals("LEFT"))
                    {
                        g_BotInvadersRect[r, c].X = g_BotInvadersRect[r, c].X - 1;
                    }
                }
            }

            String m_BotInvadersChangeDirection = "N";

            for (int r = 0; r < m_InvaderRows; r++)
            {
                for (int c = 0; c < m_InvaderCollumns; c++)
                {
                    if (g_BotInvadersRect[r, c].X + g_BotInvadersRect[r, c].Width > m_RightSide)
                    {
                        m_BotInvadersDirection = "LEFT";
                        m_BotInvadersChangeDirection = "Y";
                    }

                    if (g_BotInvadersRect[r, c].X < m_LeftSide)
                    {
                        m_BotInvadersDirection = "RIGHT";
                        m_BotInvadersChangeDirection = "Y";
                    }
                }

                if (m_BotInvadersChangeDirection.Equals("Y"))
                {
                    for (int c = 0; c < m_InvaderCollumns; c++)
                    {
                        g_BotInvadersRect[r, c].Y = g_BotInvadersRect[r, c].Y + 3;
                    }
                }
            }
        }

        public void Draw(Texture2D texture, Rectangle[,] destinationRect, Nullable<Rectangle> sourceRect, Color color, SpriteBatch spriteBatch)
        {
            for (int r = 0; r < m_InvaderRows; r++)
            {
                for (int c = 0; c < m_InvaderCollumns; c++)
                {
                    spriteBatch.Draw(g_BotInvaderTex, g_BotInvadersRect[r, c], g_BotInvaderHitBox, Color.White);
                }
            }
        }
    }
}

我不认为精灵应该按比例放大,毕竟我给了scale参数1.0f???

通过1,而不是0!比例是一个乘数,但我还是得到了同样的结果。还有其他建议吗?@Cameron看起来它永远不会改变我赋予它的任何价值。有什么问题吗?我已经编辑了你的标题。请看,如果一致意见是否定的,他们就不应该这样做。请查看其中一些链接以获取示例| |||
botInvader.Draw(botInvaders.g_BotInvaderTex, botInvaders.g_BotInvaderPos, botInvaders.g_BotInvadersRect, botInvaders.g_BotInvaderHitBox, Color.White, 0f, botInvaders.g_BotInvaderOrigin, SpriteEffects.None, 1.0f, spriteBatch);