public static void AddCamera(Camera2D camera) { if (!Cameras.Contains(camera)) { Cameras.Add(camera); } }
public void SetActiveCamera(Camera camera) { if (!Cameras.Contains(camera)) { throw new Exception("Camera must be added to world before being set as active"); } ActiveCamera = camera; }
public Camera AddCamera(Camera camera) { if (!Cameras.Contains(camera)) { Cameras.Add(camera); } return(camera); }
/** * Called by <code>FlxG.drawPlugins()</code> after the game state has been * drawn. Cycles through cameras and calls <code>drawDebug()</code> on each * one. */ public override void draw() { //FlxCamera camera = FlxG.getActiveCamera(); FlxCamera camera = FlxG.camera; if (Cameras == null) { Cameras = FlxG.cameras; } if (!Cameras.Contains(camera)) { return; } if (FlxG.visualDebug && !IgnoreDrawDebug) { drawDebug(camera); } }
/// <summary> /// 创建SceneViewModel /// </summary> /// <param name="scene"></param> public SceneViewModel(Scene scene) { if (scene != null) { Scene = scene; SceneName = scene.Name; //还原已选择的相机 if ((Scene?.VisionFrame?.IsEnableCamera == true) && (Scene?.IsCameraInit == true)) { if ((CameraFactory.Cameras.ContainsKey(Scene.CameraSerial ?? "")) && (Cameras.Contains(CameraFactory.Cameras[Scene.CameraSerial]))) { SelectedCamera = CameraFactory.Cameras[Scene.CameraSerial]; } } } }
public override void draw() { if (_flickerTimer != 0) { _flicker = !_flicker; if (_flicker) { return; } } FlxCamera camera = FlxG.camera; //._activeCamera; if (Cameras == null) { Cameras = FlxG.cameras; } if (!Cameras.Contains(camera)) { return; } if (!onScreen(camera)) { return; } _tagPoint.X = X - (camera.Scroll.X * ScrollFactor.X) - Offset.X; _tagPoint.Y = Y - (camera.Scroll.Y * ScrollFactor.Y) - Offset.Y; _tagPoint.X += (_tagPoint.X > 0) ? 0.0000001f : -0.0000001f; _tagPoint.Y += (_tagPoint.Y > 0) ? 0.0000001f : -0.0000001f; // scaling if (Scale.X != 1f || Scale.Y != 1f) { //_textField.getFont().setScale(Scale.X, Scale.Y); calcFrame(); } // position //_textField.setPosition(_tagPoint.X, _tagPoint.Y); // rotation if (Angle != 0) { /* * _matrix = FlxG.Batch.getTransformMatrix().cpy(); * * Matrix4 rotationMatrix = FlxG.batch.getTransformMatrix(); * rotationMatrix.translate(_textField.getX() + (width / 2), _textField.getY() + (height / 2), 0); * rotationMatrix.rotate(0, 0, 1, angle); * rotationMatrix.translate(-(_textField.getX() + (width / 2)), -(_textField.getY() + (height / 2)), 0); * * FlxG.batch.setTransformMatrix(rotationMatrix); */ } /* * // blending * if(blend != null && currentBlend != blend) * { * int[] blendFunc = BlendMode.getOpenGLBlendMode(blend); * FlxG.batch.setBlendFunction(blendFunc[0], blendFunc[1]); * } * else if(FlxG.batchShader == null || ignoreBatchShader) * { * // OpenGL ES 2.0 shader render * renderShader(); * // OpenGL ES 2.0 blend mode render * renderBlend(); * } */ // distance field if (_distanceFieldEnabled) { drawDistanceField(); } int tintColor; /* * // Render shadow behind the text * if(_shadow != 0) * { * // tinting * tintColor = FlxU.multiplyColors(_shadow, camera.getColor()); * _textField.setColors(((tintColor >> 16) & 0xFF) * 0.00392f, ((tintColor >> 8) & 0xFF) * 0.00392f, (tintColor & 0xFF) * 0.00392f, ((_shadow >> 24) & 0xFF) * _alpha * 0.00392f); * _textField.translate(_shadowX, _shadowY); * _textField.draw(FlxG.batch); * _textField.translate(-_shadowX, -_shadowY); * } * * // tinting * tintColor = FlxU.multiplyColors(_color, camera.getColor()); * _textField.setColors(((tintColor >> 16) & 0xFF) * 0.00392f, ((tintColor >> 8) & 0xFF) * 0.00392f, (tintColor & 0xFF) * 0.00392f, _alpha); * * _textField.draw(FlxG.batch); * * // turn off distance field * if(_distanceFieldEnabled) * FlxG.batch.setShader(null); * * // rotation * if(Angle != 0) * FlxG.batch.setTransformMatrix(_matrix); * * _VISIBLECOUNT++; * * if(FlxG.visualDebug && !ignoreDrawDebug) * drawDebug(camera); */ Point point = bounds.Center; Vector2 pos = new Vector2(point.X, point.Y); if (_alignment == "RIGHT") { pos.X += Width - textWidth; } if (_alignment == "CENTER") { pos.X += ((Width - textWidth) / 2); } pos.Y += ((Height - textHeight) / 2); // Render shadow behind the text if (_shadow != Color.Transparent) { FlxS.SpriteBatch.DrawString(LoadedFont, text, new Vector2(pos.X + _shadowX, pos.Y + _shadowY), _shadow, 0, origin, _size / _default_size, SpriteEffects.None, 0); } FlxS.SpriteBatch.DrawString(LoadedFont, text, pos, Color, 0, origin, _size / _default_size, SpriteEffects.None, 0); }