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


C# Camera.ConvertToCamera方法代碼示例

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


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

示例1: BeginDraw

        public void BeginDraw(Camera camera)
        {
            SpriteBatch spriteBatch = OGE.SpriteBatch;
            Vector2 origin = new Vector2(lightTexture.Width / 2, lightTexture.Height / 2);
            Vector2 cameraPosition;
            Rectangle lightRectangle;
            int width, height;

            OGE.GraphicDevice.SetRenderTarget(renderTarget);
            OGE.GraphicDevice.Clear(new Color(AmbientLight, AmbientLight, AmbientLight));

            spriteBatch.Begin(OGE.SpriteSortMode, OGE.BlendState);

            foreach (LightSource light in lightingSources)
            {
                width = (int)(lightTexture.Width * light.Scale);
                height = (int)(lightTexture.Height * light.Scale);
                lightRectangle = new Rectangle((int)(light.Position.X - width / 2), (int)(light.Position.Y - height / 2), width, height);

                if (camera.CheckRectangleInCamera(lightRectangle))
                {
                    cameraPosition = camera.ConvertToCamera(light.Position);
                    spriteBatch.Draw(lightTexture, cameraPosition, null, light.TintColor * light.Alpha, 0, origin,
                        light.Scale, SpriteEffects.None, 0);
                }
            }

            spriteBatch.End();

            OGE.GraphicDevice.SetRenderTarget(null);
        }
開發者ID:amidos2006,項目名稱:CleanEmUp,代碼行數:31,代碼來源:LightingSystem.cs

示例2: Draw

        public override void Draw(Vector2 position, Camera camera)
        {
            SpriteBatch spriteBatch = OGE.SpriteBatch;

            if (!camera.CheckRectangleInCamera(new Rectangle((int)position.X, (int)position.Y, Width, Height)))
            {
                return;
            }

            spriteBatch.Begin(OGE.SpriteSortMode, OGE.BlendState);

            spriteBatch.Draw(texture, camera.ConvertToCamera(position + new Vector2(0, 0)), sourceRectangle, tintColor * Alpha,
                angle, origin, scale, SpriteEffects.FlipHorizontally, 0);
            spriteBatch.Draw(texture, camera.ConvertToCamera(position + new Vector2(camera.Width - Width, 0)), sourceRectangle, tintColor * Alpha,
                angle, origin, scale, SpriteEffects.None, 0);
            spriteBatch.Draw(texture, camera.ConvertToCamera(position + new Vector2(0, camera.Height - Height)), sourceRectangle, tintColor * Alpha,
                angle, origin, scale, SpriteEffects.FlipHorizontally | SpriteEffects.FlipVertically, 0);
            spriteBatch.Draw(texture, camera.ConvertToCamera(position + new Vector2(camera.Width - Width, camera.Height - Height)), sourceRectangle, tintColor * Alpha,
                angle, origin, scale, SpriteEffects.FlipVertically, 0);

            spriteBatch.End();
        }
開發者ID:amidos2006,項目名稱:CleanEmUp,代碼行數:22,代碼來源:RedHitEffectImage.cs

示例3: Draw

        public override void Draw(Vector2 position, Camera camera)
        {
            SpriteBatch spriteBatch = OGE.SpriteBatch;

            if (!camera.CheckRectangleInCamera(new Rectangle((int)position.X, (int)position.Y, Width, Height)))
            {
                return;
            }

            spriteBatch.Begin(OGE.SpriteSortMode, BlendState.Additive);

            spriteBatch.Draw(texture, camera.ConvertToCamera(position), sourceRectangle, tintColor * Alpha, angle, origin, scale, flipping, 0);

            spriteBatch.End();
        }
開發者ID:amidos2006,項目名稱:CleanEmUp,代碼行數:15,代碼來源:AdditiveWhiteImage.cs

示例4: Draw

        /// <summary>
        /// Draw the texture in the correct position
        /// </summary>
        /// <param name="position">position of the image to be drawn at</param>
        /// <param name="camera">camera position in the scene</param>
        public virtual void Draw(Vector2 position, Camera camera)
        {
            SpriteBatch spriteBatch = OGE.SpriteBatch;

            Vector2 leftUpperCorner = OGE.GetLeftUpperCorner(position, origin);

            if (!camera.CheckRectangleInCamera(new Rectangle((int)leftUpperCorner.X, (int)leftUpperCorner.Y, Width, Height)))
            {
                return;
            }

            spriteBatch.Begin(OGE.SpriteSortMode, OGE.BlendState);

            spriteBatch.Draw(texture, camera.ConvertToCamera(position), sourceRectangle, tintColor, angle, origin, scale, flipping, 0);

            spriteBatch.End();
        }
開發者ID:amidos2006,項目名稱:CleanEmUp,代碼行數:22,代碼來源:Image.cs

示例5: BeginDraw

        public void BeginDraw(Camera camera)
        {
            //CleanUpSystem(true);

            SpriteBatch spriteBatch = OGE.SpriteBatch;
            Vector2 origin;
            Vector2 cameraPosition;
            Rectangle particleRectangle;

            OGE.GraphicDevice.SetRenderTarget(renderTarget);
            OGE.GraphicDevice.Clear(new Color(0, 0, 0, 0));

            spriteBatch.Begin(OGE.SpriteSortMode, blendState);

            spriteBatch.Draw(oldRenderTarget, camera.ConvertToCamera(oldPosition), Color.White * AlphaOldTarget);

            foreach (Particle particle in particles)
            {
                origin = new Vector2(particle.Texture.Width/2,particle.Texture.Height/2);
                particleRectangle = new Rectangle((int)(particle.Position.X - particle.Texture.Width / 2),
                    (int)(particle.Position.Y - particle.Texture.Height / 2), particle.Texture.Width, particle.Texture.Height);

                if(camera.CheckRectangleInCamera(particleRectangle))
                {
                    cameraPosition = camera.ConvertToCamera(particle.Position);
                    spriteBatch.Draw(particle.Texture, cameraPosition, particle.SourceRectangle, particle.ParticleColor * particle.Alpha,
                        MathHelper.ToRadians(particle.Angle), origin, particle.Scale, SpriteEffects.None, 0);
                }
            }

            spriteBatch.End();

            OGE.GraphicDevice.SetRenderTarget(oldRenderTarget);
            OGE.GraphicDevice.Clear(new Color(0, 0, 0, 0));
            spriteBatch.Begin(OGE.SpriteSortMode, OGE.BlendState);
            spriteBatch.Draw(renderTarget, new Vector2(), Color.White);
            spriteBatch.End();
            oldPosition.X = camera.X;
            oldPosition.Y = camera.Y;

            OGE.GraphicDevice.SetRenderTarget(null);
        }
開發者ID:amidos2006,項目名稱:CleanEmUp,代碼行數:42,代碼來源:ParticleEffectSystem.cs

示例6: Draw

        /// <summary>
        /// Draw the backdrop on the screen
        /// </summary>
        /// <param name="position"> starting position of the background</param>
        /// <param name="camera">camera object</param>
        public override void Draw(Vector2 position, Camera camera)
        {
            SpriteBatch spriteBatch = OGE.SpriteBatch;

            Vector2 tempPosition = new Vector2();
            Vector2 startingPosition = new Vector2();
            Point textureDimension = sourceRectangle == null ? new Point(texture.Width, texture.Height) :
                new Point(sourceRectangle.Value.Width, sourceRectangle.Value.Height);
            int xLoop = 1;
            int yLoop = 1;

            startingPosition = camera.ConvertToCamera(position, relativeSpeed);

            if (repeatX)
            {
                xLoop = (camera.Width) / textureDimension.X + 2;
                startingPosition.X = OGE.NumberWrap((int)(startingPosition.X + textureDimension.X), 0, textureDimension.X)
                    - textureDimension.X;
            }

            if (repeatY)
            {
                yLoop = (camera.Height) / textureDimension.Y + 2;
                startingPosition.Y = OGE.NumberWrap((int)(startingPosition.Y + textureDimension.Y), 0, textureDimension.Y)
                    - textureDimension.Y;
            }

            tempPosition.X = startingPosition.X;
            tempPosition.Y = startingPosition.Y;

            spriteBatch.Begin(OGE.SpriteSortMode, OGE.BlendState);

            for (int y = 0; y < yLoop; y++)
            {
                for (int x = 0; x < xLoop; x++)
                {
                    spriteBatch.Draw(texture, tempPosition, sourceRectangle, tintColor);
                    tempPosition.X += textureDimension.X;
                }
                tempPosition.Y += textureDimension.Y;
                tempPosition.X = startingPosition.X;
            }

            spriteBatch.End();
        }
開發者ID:amidos2006,項目名稱:CleanEmUp,代碼行數:50,代碼來源:Backdrop.cs


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