SetRelativeFromAbsolute
Introduction
Details
Code Example
using FlatRedBall.Graphics; Sprite parent = SpriteManager.AddSprite("redball.bmp");
Sprite child = SpriteManager.AddSprite("redball.bmp");
child.AttachTo(parent, false);
// At this point, both child and parent have a position of (0,0,0)
child.X = 9;
child.Y = 10;
// Right now the child really is positioned at (9,10,0). If we did nothing more
// the child would remain at this position until it is drawn, at which point
// it would get repositioned back to (0,0,0) according to its parent's absolute
// values and its own relative values...
// BUT NOT SO FAST! We can quickly modify the relative values right now before
// any drawing occurs to change the relative values:
child.SetRelativeFromAbsolute();
// Now the child has the same absolute value (9,10,0), plus its relative values
// have been modified so that it will stay in that same spot.
Another way to think about it...
Last updated
Was this helpful?