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


C# Camera2D類代碼示例

本文整理匯總了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;
 }
開發者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


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