本文整理汇总了C#中Camera.CheckRectangleInCamera方法的典型用法代码示例。如果您正苦于以下问题:C# Camera.CheckRectangleInCamera方法的具体用法?C# Camera.CheckRectangleInCamera怎么用?C# Camera.CheckRectangleInCamera使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Camera
的用法示例。
在下文中一共展示了Camera.CheckRectangleInCamera方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
示例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, BlendState.Additive);
spriteBatch.Draw(texture, camera.ConvertToCamera(position), sourceRectangle, tintColor * Alpha, angle, origin, scale, flipping, 0);
spriteBatch.End();
}
示例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, 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();
}
示例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();
}
示例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);
}