Пример #1
0
        public void BakeRotation()
        {
            PointF[] array = new PointF[1]
            {
                PointF.Empty
            };
            TmxMath.RotatePoints(array, this);
            float x = Position.X - array[0].X;
            float y = Position.Y - array[0].Y;

            Position = new PointF(x, y);
            Position = TmxMath.Sanitize(Position);
            Rotation = 0f;
        }
Пример #2
0
        public void BakeRotation()
        {
            // Rotate (0, 0)
            PointF[] pointfs = new PointF[1] {
                PointF.Empty
            };
            TmxMath.RotatePoints(pointfs, this);

            // Bake that rotation into our position, sanitizing the result
            float x = this.Position.X - pointfs[0].X;
            float y = this.Position.Y - pointfs[0].Y;

            this.Position = new PointF(x, y);
            this.Position = TmxMath.Sanitize(this.Position);

            // Null out our rotation
            this.Rotation = 0;
        }
Пример #3
0
 private void FixTileColliderObjects(TmxMap tmxMap)
 {
     for (int i = 0; i < ObjectGroup.Objects.Count; i++)
     {
         TmxObject tmxObject = ObjectGroup.Objects[i];
         if (tmxObject is TmxObjectRectangle)
         {
             TmxObjectPolygon value = TmxObjectPolygon.FromRectangle(tmxMap, tmxObject as TmxObjectRectangle);
             ObjectGroup.Objects[i] = value;
         }
     }
     foreach (TmxObject @object in ObjectGroup.Objects)
     {
         TmxHasPoints tmxHasPoints = @object as TmxHasPoints;
         if (tmxHasPoints != null)
         {
             PointF[] array = tmxHasPoints.Points.ToArray();
             TmxMath.RotatePoints(array, @object);
             array = array.Select(TmxMath.Sanitize).ToArray();
             tmxHasPoints.Points = array.ToList();
             @object.BakeRotation();
         }
     }
 }