private void resetBackground(BackgroundComponent background) { if (!float.IsNaN(defaultVector.X) && !float.IsNaN(defaultVector.Y)) { background.Vector = defaultVector; } }
public override void update(IComponent component) { BackgroundComponent background = component as BackgroundComponent; if (!initialized) { resetBackground(background); initializeBackground(background); initialized = true; } Vector2 temp = new Vector2(); temp.X = (distance.X / transition.Interval); temp.Y = (distance.Y / transition.Interval); int x = (int)(defaultVector.X - background.Vector.X); int y = (int)(defaultVector.Y - background.Vector.Y); if (((Math.Abs(x) < Math.Abs(temp.X)) || (Math.Abs(y) < Math.Abs(temp.Y))) && transition.State == TransitionState.intro) { background.Vector = defaultVector; } else { background.Vector += temp; } transition.update(component); }
private void initializeBackground(BackgroundComponent background) { if (transition.State == TransitionState.intro) { defaultVector = background.Vector; Vector2 temp = new Vector2(); temp = background.Vector + offset; background.Vector = temp; distance = defaultVector - temp; } else if (transition.State == TransitionState.exit || transition.State == TransitionState.selected) { defaultVector = background.Vector; Vector2 temp = new Vector2(); temp = defaultVector + offset; distance = defaultVector - temp; } }
private void setAlpha(BackgroundComponent background) { Color temp = background.BackgroundColor; temp.A = (byte)alpha; background.BackgroundColor = temp; }
public override void setTransition(IComponent component) { BackgroundComponent background = component as BackgroundComponent; initializeBackground(background); initialized = true; transition.setTransition(component); }
private void resetBackground(BackgroundComponent background) { if (defaultAlpha > 0) { alpha = defaultAlpha; setAlpha(background); } }
private void initializeBackground(BackgroundComponent background) { defaultAlpha = background.BackgroundColor.A; //Set the fade to fade in if (transition.State == TransitionState.intro) { direction = 255; alpha = 0; setAlpha(background); } //Else set the fade to fade out; else if (transition.State == TransitionState.exit || transition.State == TransitionState.selected) { direction = -255; alpha = 255; setAlpha(background); } }
public override void update(IComponent component) { BackgroundComponent background = component as BackgroundComponent; if (!initialized) { resetBackground(background); initializeBackground(background); initialized = true; } int x = 255 - alpha; int y = direction / transition.Interval; if (x >= y) { alpha += direction / transition.Interval; } setAlpha(background); transition.update(component); }