Moves the background in the opposite direction of player cursor. As seen in Chata - enn.
Creates a pretty sharp screen move effect. The background moves opposite to the direction of the next hitobjects, so in gameplay it looks like the background is parallax with the cursor. Script includes a parameter for start/end fade for smooth transitions. Fade out opacity can also be configured.
Script
public void parallaxer(string BackgroundPath, int StartFade, int StartTime, int EndTime, int EndFade, int EndOpacity, float amt){
var bitmap = GetMapsetBitmap(BackgroundPath);
var bg = GetLayer("bg").CreateSprite(BackgroundPath);
bg.Scale(StartTime, (570.0f / bitmap.Height)+0.1);
var Beat = Beatmap.GetTimingPointAt(StartTime).BeatDuration;
Vector2 screenCenter = new Vector2(320,240);
Vector2 Position;
Vector2 oldPosition = screenCenter;
Vector2 Direction;
double lastTime = StartTime;
bg.Fade(StartFade, StartTime, 0, 1);
bg.Fade(EndTime, EndFade, 1, EndOpacity);
foreach(var hitobject in Beatmap.HitObjects){
if(hitobject.StartTime >= StartTime && hitobject.StartTime <= EndTime){
Direction = (screenCenter+hitobject.Position)*amt;
Position = screenCenter+Direction;
bg.Move(OsbEasing.InOutQuad, lastTime, hitobject.StartTime, oldPosition, Position);
oldPosition = Position;
lastTime = hitobject.StartTime;
}
}
}
Example Usage
var Start = 0; //change to any beatmap timing point
var Beat = Beatmap.GetTimingPointAt(Start).BeatDuration;
//usually a move amount of 0.015f is good, increase/decrease if needed
parallaxer("bg.jpg",132748,132748+beat, 150431, 150431+beat,0,0.015f);