示例#1
0
        /// <summary>
        /// Passes the entire layer to the user. The SketchManager is no longer managing the life cycle of the layer.
        /// Failure to properly manage the layer will result in a memory leak, among other problems.
        /// This method should be called after <see cref="End()"/>.
        /// </summary>
        /// <returns>Returns the entire layer that was just created.</returns>
        public static RenderTarget2D InterceptRelay()
        {
            SketchManager.RegisterStage(StageType.Post);

            // Make sure that this method is always called after End(spriteBatch).
            if (!SketchManager.VerifyQueue(StageType.Setup, StageType.Begin, StageType.End, StageType.Post))
            {
                throw new RelatusException("InterceptRelay() must be called after End(spriteBatch).", new MethodOrderException());
            }

            // Make sure that DisableRelay() was called.
            if (result == null)
            {
                throw new RelatusException("There is nothing to intercept. Make sure to call DisableRelay() before calling Begin(spriteBatch)", new MethodOrderException());
            }

            SketchManager.GiveUpControl();
            disableRelay        = false;
            preventFumbledRelay = false;

            return(result);
        }