FRBDK/SpriteEditor/GameData.cs
/// <summary>
/// This scaled and adjusts relative positions when using a root control Sprite.
/// The method assumes that the Sprite s is parallel or perpendicular to its parent Sprite.
/// </summary>
/// <param name="s">The Sprite to scale and move.</param>
/// <param name="ScaleX">The parent Sprite's ScaleX percentage change.</param>
/// <param name="ScaleY">The parent Sprite's ScaleY percentage change.</param>
/// <param name="sclZ">The parent Sprite's sclZ percentage change (won't scale parent).</param>
This scaled and adjusts relative positions when using a root control Sprite.
The method assumes that the Sprite s is parallel or perpendicular to its parent Sprite.
This scaled and adjusts relative positions when using a root control Sprite . The method assumes that the Sprite s is parallel or perpendicular to its parent Sprite .
public static void ApplyRelativeScale(Sprite s, float ScaleX, float ScaleY)
		{
			if(s == mEditorLogic.EditAxes .origin)	return; 
			if(InputManager.Keyboard.KeyDown(Key.LeftShift) == false && InputManager.Keyboard.KeyDown(Key.RightShift) == false)
			{
                Sprite topParent = (Sprite)s.TopParent;
                Sprite parent = (Sprite)s.Parent;
                float xDifference = s.X - topParent.X;
                float yDifference = s.Y - topParent.Y;
                s.Detach();
                if ((s.RotationZ > (float)System.Math.PI * 0.25f && s.RotationZ < (float)System.Math.PI * 0.75f) ||
                    (s.RotationZ > (float)System.Math.PI * 1.25f && s.RotationZ < (float)System.Math.PI * 1.75f))
                {
                    s.ScaleX *= ScaleY + 1;
                    s.ScaleY *= ScaleX + 1;
                }
                else
                {
                    s.ScaleX *= ScaleX + 1;
                    s.ScaleY *= ScaleY + 1;
                }
                s.X = topParent.X + xDifference * (ScaleX + 1);
                s.Y = topParent.Y + yDifference * (ScaleY + 1);
                s.AttachTo(parent, true);
				for(int i = s.Children.Count - 1; i > -1; i--)
					ApplyRelativeScale((Sprite)(s.Children[i]), ScaleX, ScaleY);
			}
			else
			{
				s.ScaleX *= ScaleX + 1;
				s.ScaleY *= ScaleY + 1;
				s.RelativeX *= ScaleX + 1;
				s.RelativeY *= ScaleY + 1;
                for (int i = s.Children.Count - 1; i > -1; i--)
                    ApplyRelativeScale((Sprite)(s.Children[i]), ScaleX, ScaleY);
            }
	    }
public static void ApplyRelativeScale ( Sprite s , float ScaleX , float ScaleY ) { if ( s == mEditorLogic . EditAxes . origin ) return ; if ( InputManager . Keyboard . KeyDown ( Key . LeftShift ) == false && InputManager . Keyboard . KeyDown ( Key . RightShift ) == false ) { Sprite topParent = ( Sprite ) s . TopParent ; Sprite parent = ( Sprite ) s . Parent ; float xDifference = s . X - topParent . X ; float yDifference = s . Y - topParent . Y ; s . Detach ( ) ; if ( ( s . RotationZ > ( float ) System . Math . PI * 0.25f && s . RotationZ < ( float ) System . Math . PI * 0.75f ) || ( s . RotationZ > ( float ) System . Math . PI * 1.25f && s . RotationZ < ( float ) System . Math . PI * 1.75f ) ) { s . ScaleX *= ScaleY + 1 ; s . ScaleY *= ScaleX + 1 ; } else { s . ScaleX *= ScaleX + 1 ; s . ScaleY *= ScaleY + 1 ; } s . X = topParent . X + xDifference * ( ScaleX + 1 ) ; s . Y = topParent . Y + yDifference * ( ScaleY + 1 ) ; s . AttachTo ( parent , true ) ; for ( int i = s . Children . Count - 1 ; i > - 1 ; i -- ) ApplyRelativeScale ( ( Sprite ) ( s . Children [ i ] ) , ScaleX , ScaleY ) ; } else { s . ScaleX *= ScaleX + 1 ; s . ScaleY *= ScaleY + 1 ; s . RelativeX *= ScaleX + 1 ; s . RelativeY *= ScaleY + 1 ; for ( int i = s . Children . Count - 1 ; i > - 1 ; i -- ) ApplyRelativeScale ( ( Sprite ) ( s . Children [ i ] ) , ScaleX , ScaleY ) ; } }
This scaled and adjusts relative positions when using a root control Sprite.
This scaled and adjusts relative positions when using a root control Sprite .
// don't want to scale the edit axes /*
				 * After rotating the scaleVector, some values may become negative.  However, if they were positive in the original
				 * we want them to stay positive.  That way, if the control point is growing, we want the attached Sprite to grow as well.
				 * The locatorVector does this, but assumes that all rotations are multiples of PI/2 on all axes
				 */
s
Sprite
The Sprite to scale and move.
The Sprite to scale and move .
ScaleX
float
The parent Sprite's ScaleX percentage change.
The parent Sprite ' s ScaleX percentage change .
ScaleY
float
The parent Sprite's ScaleY percentage change.
The parent Sprite ' s ScaleY percentage change .
sclZ
The parent Sprite's sclZ percentage change (won't scale parent).
The parent Sprite ' s sclZ percentage change ( won ' t scale parent ) .