本文整理汇总了C#中Camera2D类的典型用法代码示例。如果您正苦于以下问题:C# Camera2D类的具体用法?C# Camera2D怎么用?C# Camera2D使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Camera2D类属于命名空间,在下文中一共展示了Camera2D类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: OnEnable
public void OnEnable()
{
_Camera = (Camera)target;
_Camera2D = _Camera.gameObject.GetComponent<Camera2D>();
_Camera2D = _Camera2D ?? _Camera.gameObject.AddComponent<Camera2D>();
_Camera2D.hideFlags = HideFlags.HideInInspector;
}
开发者ID:bmotamer,项目名称:tiled,代码行数:7,代码来源:Camera2DEditor.cs
示例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);
}
}
}
}
开发者ID:Noxalus,项目名称:Final-Bomber,代码行数:30,代码来源:MapLayer.cs
示例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();
}
开发者ID:EmptyKeys,项目名称:MonoGame.Extended,代码行数:7,代码来源:TiledImageLayer.cs
示例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);
}
}
开发者ID:alongubkin,项目名称:Plutonium,代码行数:25,代码来源:DrawTool.cs
示例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();
}
开发者ID:zanagi,项目名称:MelSpaceHunter,代码行数:7,代码来源:Screen.cs
示例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);
}
开发者ID:Neojin9,项目名称:RLRedux,代码行数:33,代码来源:ProjectileIconObj.cs
示例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();
}
开发者ID:Azarem,项目名称:RogueAPI,代码行数:26,代码来源:RenderStep.cs
示例8: Draw
public void Draw(SpriteBatch spriteBatch, Camera2D camera)
{
foreach (MapLayer layer in mapLayers)
{
layer.Draw(camera, tilesets);
}
}
开发者ID:Noxalus,项目名称:Final-Bomber,代码行数:7,代码来源:TileMap.cs
示例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>();
}
开发者ID:maxrevilo,项目名称:Juego2D,代码行数:7,代码来源:Scenario.cs
示例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;
}
开发者ID:TheEternalCircle,项目名称:TheEternalCircleMasterSolution,代码行数:26,代码来源:HParallax.cs
示例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();
}
开发者ID:Grutn,项目名称:TDT4240-X2,代码行数:29,代码来源:ControllerViewManager.cs
示例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);
}
开发者ID:alongubkin,项目名称:Plutonium,代码行数:7,代码来源:EraserTool.cs
示例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);
}
}
开发者ID:Neojin9,项目名称:RLRedux,代码行数:7,代码来源:TerrainObj.cs
示例14: GameWorld
public GameWorld(Vector2 gravity, float airDrag, Camera2D camera)
: base(gravity)
{
this.camera = camera;
this.airDrag = airDrag;
this.BodyAdded += BodyAddedHandler;
}
开发者ID:maxrevilo,项目名称:Juego2D,代码行数:7,代码来源:GameWorld.cs
示例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;
}
开发者ID:PhoenixWright,项目名称:NePlus,代码行数:29,代码来源:Engine.cs
示例16: LoadContent
public override void LoadContent()
{
if (Camera == null)
{
Camera = new Camera2D(ScreenManager.GraphicsDevice);
}
iHUD = ScreenManager.Game.Services.GetService(typeof(IHUD)) as IHUD;
iVisualiser = ScreenManager.Game.Services.GetService(typeof(IVisualiser)) as IVisualiser;
//Swinger texture
SwingerTexture = ScreenManager.Content.Load<Texture2D>("Common/slider");
//Halo texture
HaloTexture = ScreenManager.Content.Load<Texture2D>("Common/halo");
//SpeedBoost texture
SpeedBoostTexture = ScreenManager.Content.Load<Texture2D>("Common/slider");
//bullet texture
BulletTexture = ScreenManager.Content.Load<Texture2D>("Common/bullet");
////////////////////////////////
//ObstacleManager
////////////////////////////////
ObstacleManager = new ObstacleManager();
ObstacleManager.LoadContent(ScreenManager);
base.LoadContent();
}
开发者ID:kbo4sho,项目名称:SwingSets.WP7,代码行数:27,代码来源:HookPointManager.cs
示例17: Update
public void Update(Camera2D _camera)
{
if (_isMoving)
UpdateMove(_camera);
else
UpdateParallax(_camera);
}
开发者ID:TheEternalCircle,项目名称:TheEternalCircleMasterSolution,代码行数:7,代码来源:HParallax.cs
示例18: Layer
public Layer(Camera2D camera, float scrollRateX = 1f, float scrollRateY = 1f)
{
Offset = new Vector2(0,0);
this.Camera = camera;
ScrollRateX = scrollRateX ;
ScrollRateY = ScrollRateY ;
}
开发者ID:edibletoaster,项目名称:PSM-Game,代码行数:7,代码来源:Layer.cs
示例19: Draw
public override void Draw(SpriteBatch spritebatch, Camera2D camera = null)
{
Vector2 r = rotationMatrix.rotate(new Vector2((int)(xPosition), (int)(yPosition)));
if (camera == null || camera.IsInView(r, texture))
{
spritebatch.Draw(texture, r, null, Color.White, 0, new Vector2(texture.Width / 2, texture.Height / 2), 1, SpriteEffects.None, 0);
}
}
开发者ID:hrkrx,项目名称:InsertNameHere,代码行数:8,代码来源:IsometricTile.cs
示例20: UpdateMove
public void UpdateMove(Camera2D _camera)
{
Matrix pos = _camera.GetTransformMatrix();
if (-pos.M41 % _width*2 == 0)
_position.X = -pos.M41 + _width;
_position.X += -_speed;
}
开发者ID:TheEternalCircle,项目名称:TheEternalCircleMasterSolution,代码行数:8,代码来源:HParallax.cs
注:本文中的Camera2D类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论