protected override CGRect GetRect(nfloat winWidth, nfloat winHeight) { nfloat min = winWidth < winHeight ? winWidth : winHeight; // a value from 0 to 1 nfloat spread = UserSettings.GetSettings().BounceWidthPad * 2; nfloat width, height, xPos, yPos; var ratio = winHeight / winWidth; var spreadRatio = 1 / (spread + 1); if (spreadRatio > ratio) { height = winHeight; width = height * (spread + 1); yPos = 0; xPos = winWidth / 2 - width / 2; } else { width = winWidth; height = width / (1 + spread); xPos = 0; yPos = winHeight / 2 - height / 2; } BounceHelper.SetDimensions(width, height); // create the elements. We need to initialize them here when all the dimensions are set. //CreateAssets(); return(new CGRect(xPos, yPos, width, height)); }
void Instance_BeatChanged(object sender, EventArgs e) { // need to create all new elements; recreate everything BounceHelper.SetDimensions(Layer.Frame.Width, Layer.Frame.Height); // redraw lanes AnimationLayer.SetNeedsDisplay(); CreateAssets(); ReturnToInitialState(); BounceHelper.ElapsedBpm = Metronome.Instance.ElapsedBpm; DrawElements(); }