Beispiel #1
0
        /// <summary>
        /// ウィンドウサイズを画像の何倍かに合わせる
        /// </summary>
        void FitWindowSize()
        {
            // 0ならサイズ調整なし
            if (m_fitScale <= 0)
            {
                return;
            }

            // 最大化されているときは調整なし
            if (m_uniwin.IsMaximized)
            {
                return;
            }

            // 画像が読み込まれていなければ何もしない
            if (currentBitmap == null)
            {
                return;
            }

            var formerSize = m_uniwin.GetWindowSize();
            var pos        = m_uniwin.GetWindowPosition();

            int width  = (int)(currentBitmap.Width * m_fitScale);
            int height = (int)(currentBitmap.Height * m_fitScale);

            // Windows向けに、ウィンドウサイズ変更後左上が固定となるよう位置調整
            pos.y = pos.y + formerSize.y - height;

            //this.ClientSize = new Size(width, height);        // Formの機能でサイズ変更する場合

            m_uniwin.SetWindowSize(new UniWinCSharp.Vector2(width, height));
            m_uniwin.SetWindowPosition(pos);
        }
Beispiel #2
0
        void BeginJumping()
        {
            isMoving        = true;
            initialPosition = uniwin.GetWindowPosition();

            startedMilliSeconds = stopwatch.ElapsedMilliseconds;

            // H = height[px]/pixelPerMeter[px/m]
            // T = duration[s] として
            // H == 1/2 * g * (T/2)^2 となるため
            // T = sqrt( 8H / g )
            duration = Math.Sqrt((height / pixelPerMeter) * 8.0 / standardGravity);
        }