0

我对 UrhoSharp 有疑问。我想加载具有 2D 纹理的室内地图图像。我使用带有盒子形状的 Octree(Urho 类)创建了一个场景,它以 3d 视图出现。那么,我怎样才能在 2D 视图中实现同样的效果,任何建议或演示都会很有帮助。

提前致谢。

4

1 回答 1

0

您可以使用 staticsprite2d 从正交相机加载 2d 纹理和视图。参考https://developer.xamarin.com/api/type/Urho.Urho2D.StaticSprite2D/

       //Create  sprite image
        var floorNode = _scene.CreateChild();
        floorNode.Position = new Vector3(0, 0, 0.0f);
        StaticSprite2D staticSprite = floorNode.CreateComponent<StaticSprite2D>();
        staticSprite.Color = Color.White;
        staticSprite.BlendMode = BlendMode.Alpha;
        var sprite = ResourceCache.GetSprite2D("floorplan_image.jpg");
        staticSprite.Sprite = sprite;

        //Create a camera
        Node cameraNode = _scene.CreateChild("camera");
        var camera = cameraNode.CreateComponent<Camera>();
        camera.Orthographic = true;
        cameraNode.Position = (new Vector3(0.0f, 0.0f, -10.0f));
        camera.OrthoSize = (float)Graphics.Height * PixelSize;
于 2018-09-10T18:10:17.797 回答