Esempio n. 1
0
        static IntPtr hide_overlay(IntPtr Self, IntPtr Args)
        {
            int frames = (int)Ruby.Integer.FromPtr(Ruby.GetIVar(Self, "@frame_rate")) / 4;

            if (Ruby.Array.Length(Args) != 0)
            {
                Ruby.Array.Expect(Args, 1);
                Ruby.Array.Expect(Args, 0, "Integer");
                frames = (int)Ruby.Integer.FromPtr(Ruby.Array.Get(Args, 0));
            }
            if (Ruby.Integer.FromPtr(Ruby.GetIVar(OverlaySprite, "@opacity")) == 0)
            {
                return(Ruby.False);
            }
            if (frames == 0)
            {
                Ruby.Funcall(OverlaySprite, "opacity=", Ruby.Integer.ToPtr(0));
                return(Ruby.True);
            }
            bool hasblock = Ruby.HasBlock();

            for (int i = 1; i <= frames; i++)
            {
                Ruby.Funcall(OverlaySprite, "opacity=", Ruby.Float.ToPtr(255 - 255d / frames * i));
                if (hasblock)
                {
                    Ruby.Yield(Ruby.Integer.ToPtr(i - 1));
                }
                update(Self, Ruby.Array.Create());
            }
            return(Ruby.True);
        }