本文整理汇总了C#中Camera2D类的典型用法代码示例。如果您正苦于以下问题:C# Camera2D类的具体用法?C# Camera2D怎么用?C# Camera2D使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Camera2D类属于命名空间,在下文中一共展示了Camera2D类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnEnable
public void OnEnable()
{
_Camera = (Camera)target;
_Camera2D = _Camera.gameObject.GetComponent<Camera2D>();
_Camera2D = _Camera2D ?? _Camera.gameObject.AddComponent<Camera2D>();
_Camera2D.hideFlags = HideFlags.HideInInspector;
}
示例2: Draw
public void Draw(Camera2D camera, List<Tileset> tilesets)
{
var destination = new Rectangle(0, 0, Engine.TileWidth, Engine.TileHeight);
// TODO: Replace this drawcall with a single drawcall to render all grass tiles
for (int y = 0; y < Height; y++)
{
destination.Y = y * Engine.TileHeight + (int)Engine.Origin.Y;
for (int x = 0; x < Width; x++)
{
Tile tile = GetTile(x, y);
if (tile.TileIndex == -1 || tile.Tileset == -1)
continue;
destination.X = x * Engine.TileWidth + (int)Engine.Origin.X;
var position = new Vector2(destination.X, destination.Y);
if (camera.IsVisible(position))
{
FinalBomber.Instance.SpriteBatch.Draw(
tilesets[tile.Tileset].Texture,
destination,
tilesets[tile.Tileset].SourceRectangles[tile.TileIndex],
Color.White);
}
}
}
}
示例3: Draw
public override void Draw(Camera2D camera)
{
_spriteBatch.Begin(sortMode: SpriteSortMode.Immediate, blendState: BlendState.AlphaBlend,
samplerState: SamplerState.PointClamp, transformMatrix: camera.GetViewMatrix());
_spriteBatch.Draw(_texture, Position, Color.White);
_spriteBatch.End();
}
示例4: DrawTile
void DrawTile(Map map, Layer layer, Camera2D camera, Vector2 position, string selectedTileName)
{
if (!string.IsNullOrEmpty(selectedTileName))
{
var point = new Vector2((int)((camera.Position.X + position.X) / 32), (int)((camera.Position.Y + position.Y) / 32));
if (layer.Tiles.ContainsKey(point))
layer.Tiles.Remove(point);
layer.Tiles.Add(point, TileRepository.GetTile(selectedTileName));
/*UndoService.Current[map].AddChange(new DelegateChange(null, new Action(() =>
{
layer.Tiles.Remove(point);
}), new Action(() =>
{
layer.Tiles.Add(point, TileRepository.GetTile(selectedTileName));
}), selectedTileName), "Draw a tile");*/
/*MainForm.MapPanel.AddShadowForObject(Texture2D.FromStream(MainForm.MapPanel.GraphicsDevice, TileRepository.GetTile(selectedTileName).Texture),
point);*/
base.OnMouseMove(map, layer, camera, position, selectedTileName);
}
}
示例5: Screen
public Screen(ScreenManager manager)
{
this.manager = manager;
this.loadComplete = false;
this.camera = new Camera2D(manager.ViewManager.Width, manager.ViewManager.Height);
this.inputManager = new InputManager();
}
示例6: Update
public void Update(Camera2D camera)
{
if (this.AttachedProjectile.X <= (float)(camera.Bounds.Left + this.m_iconOffset))
{
base.X = (float)this.m_iconOffset;
}
else if (this.AttachedProjectile.X > (float)(camera.Bounds.Right - this.m_iconOffset))
{
base.X = (float)(1320 - this.m_iconOffset);
}
else
{
base.X = this.AttachedProjectile.X - camera.TopLeftCorner.X;
}
if (this.AttachedProjectile.Y <= (float)(camera.Bounds.Top + this.m_iconOffset))
{
base.Y = (float)this.m_iconOffset;
}
else if (this.AttachedProjectile.Y > (float)(camera.Bounds.Bottom - this.m_iconOffset))
{
base.Y = (float)(720 - this.m_iconOffset);
}
else
{
base.Y = this.AttachedProjectile.Y - camera.TopLeftCorner.Y;
}
base.Rotation = CDGMath.AngleBetweenPts(camera.TopLeftCorner + base.Position, this.AttachedProjectile.Position);
this.m_iconBG.Position = base.Position;
this.m_iconBG.Rotation = base.Rotation;
this.m_iconProjectile.Position = base.Position;
this.m_iconProjectile.Rotation = this.AttachedProjectile.Rotation;
this.m_iconProjectile.GoToFrame(this.AttachedProjectile.CurrentFrame);
}
示例7: Draw
public void Draw(Camera2D camera, GameTime gameTime)
{
if (PreSteps.Count > 0)
foreach (var s in PreSteps)
s(camera, this, gameTime);
if (Skip)
return;
camera.GraphicsDevice.SetRenderTarget(RenderTarget);
if (ClearColor != null)
camera.GraphicsDevice.Clear(ClearColor.Value);
if (ShaderSteps.Count > 0)
foreach (var s in ShaderSteps)
s.Prepare(camera);
camera.Begin(SpriteSortMode, BlendState, SamplerState, DepthStencilState, RasterizerState, Effect, TransformMatrix);
if (DrawSteps.Count > 0)
foreach (var s in DrawSteps)
s(camera, this, gameTime);
camera.End();
}
示例8: Draw
public void Draw(SpriteBatch spriteBatch, Camera2D camera)
{
foreach (MapLayer layer in mapLayers)
{
layer.Draw(camera, tilesets);
}
}
示例9: Scenario
public Scenario(GameScreen gameScreen, GameWorld world, Camera2D camera)
: base(gameScreen, world, camera)
{
levelNumber = 0;
physics.bodys = new Body[1]{ new Body(world) };
images = new List<SpriteSheet>();
}
示例10: UpdateParallax
public void UpdateParallax(Camera2D _camera)
{
Matrix pos = _camera.GetParallaxMatrix(_speed);
if (_camera.IsPlayerFollow)
{
_position.X = -pos.M41 - (int)-pos.M41 % _width;
_position2.X = _position.X + _width;
}
else
{
if (-pos.M41 > _position2.X + -_camera.Translation.X &&
-pos.M41 < _position2.X + _width)
_position.X = _position2.X + _width;
else
_position.X = _position2.X - _width;
if (-pos.M41 > _position.X + -_camera.Translation.X &&
-pos.M41 < _position.X + _width)
_position2.X = _position.X + _width;
else
_position2.X = _position.X - _width;
}
_position.Y = -pos.M42;
_position2.Y = -pos.M42;
}
示例11: ControllerViewManager
public ControllerViewManager(GraphicsDevice graphicsDevice, ContentManager content)
{
controllers = new List<Controller>();
views = new List<IView>();
this.content = content;
this.graphicsDevice = graphicsDevice;
this.batch = new SpriteBatch(graphicsDevice);
this.world = new World(new Vector2(0, Constants.GamePlayGravity));
this.controllerQueue = new ConcurrentQueue<Tuple<Controller, QueueState>>();
this.viewQueue = new ConcurrentQueue<Tuple<IView, QueueState>>();
if (Constants.DebugMode && debugView == null)
{
debugView = new DebugViewXNA(world);
debugView.AppendFlags(DebugViewFlags.DebugPanel);
debugView.DefaultShapeColor = Color.Red;
debugView.SleepingShapeColor = Color.Green;
debugView.LoadContent(graphicsDevice, content);
}
if (camera == null)
{
Viewport v = graphicsDevice.Viewport;
camera = new Camera2D(graphicsDevice);
camera.Position = new Vector2(v.Width / 2, v.Height / 2);
}
else camera.ResetCamera();
}
示例12: Draw
public override void Draw(SpriteBatch spriteBatch, Camera2D camera, Vector2 mousePosition, Texture2D pixel)
{
spriteBatch.Draw(pixel, new Rectangle((int)((camera.Position.X + mousePosition.X) / 32) * 32 + 1, (int)((camera.Position.Y + mousePosition.Y) / 32) * 32, 32, 32),
Color.Orange);
base.Draw(spriteBatch, camera, mousePosition, pixel);
}
示例13: Draw
public override void Draw(Camera2D camera)
{
if ((this.ShowTerrain && CollisionMath.Intersects(this.Bounds, camera.Bounds)) || base.ForceDraw)
{
camera.Draw(Game.GenericTexture, base.Position, new Rectangle?(new Rectangle(0, 0, this.Width, this.Height)), base.TextureColor, MathHelper.ToRadians(base.Rotation), Vector2.Zero, 1f, SpriteEffects.None, 0f);
}
}
示例14: GameWorld
public GameWorld(Vector2 gravity, float airDrag, Camera2D camera)
: base(gravity)
{
this.camera = camera;
this.airDrag = airDrag;
this.BodyAdded += BodyAddedHandler;
}
示例15: Engine
public Engine(ContentManager content, ScreenManager screenManager)
{
this.ScreenManager = screenManager;
components = new List<Component>();
componentsToBeAdded = new List<Component>();
componentsToBeRemoved = new List<Component>();
Content = content;
Audio = new Audio(this);
Input = new InputState();
Physics = new Physics(this);
Video = new Video(this);
// these things require video
Camera = new Camera2D(this);
// lighting needs to know the camera matrix
Lighting = new Lighting(this);
SpriteBatch = new SpriteBatch(Global.GraphicsDeviceManager.GraphicsDevice);
BloomComponent = new BloomComponent(this);
BloomComponent.DrawOrder = int.MaxValue;
BloomComponent.LoadContent();
Updating = false;
}