Beispiel #1
0
        private void CreateRectangle(TiledObject obj)
        {
            float rectWidth  = ConvertUnits.ToSimUnits(obj.Width);
            float rectHeight = ConvertUnits.ToSimUnits(obj.Height);

            var body = BodyFactory.CreateRectangle(
                physicsWorld, rectWidth, rectHeight, obj.GetDensity());

            body.Position      = obj.GetObjectCenter();
            body.FixedRotation = true;
            body.BodyType      = BodyType.Static;
        }
Beispiel #2
0
        public DrawableEntity(World world, TiledObject obj, TextureRegion2D textureRegion)
            : base(world, obj)
        {
            if (textureRegion == null)
            {
                throw new ArgumentNullException(nameof(textureRegion));
            }

            halfSize           = ConvertUnits.ToSimUnits(new Vector2(obj.Width / 2.0f, obj.Height / 2.0f));
            this.textureRegion = textureRegion;
            Body.Position      = obj.GetObjectCenter();
            Body.BodyType      = obj.GetBodyType();
        }