当前位置: 首页>>代码示例>>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;未经允许,请勿转载。