/// <summary> /// Initializes the control, creating the ContentManager /// and using it to load a SpriteFont. /// </summary> protected override void Initialize() { //content = new ContentManager(Services, "Content"); // timer = Stopwatch.StartNew(); GraphicsDevice.BlendState = BlendState.AlphaBlend; GraphicsDevice.DepthStencilState = DepthStencilState.DepthRead; //contentBuilder = new ContentBuilder(); //contentManager = new ContentManager(this.Services, // contentBuilder.OutputDirectory); spriteBatch = new SpriteBatch(GraphicsDevice); // string assemblyLocation = Assembly.GetExecutingAssembly().Location; string execPath = Path.GetDirectoryName(assemblyLocation); string scBGTex = execPath + "\\Scene_SpriteBG.png"; string mokujunTex = execPath + "\\player_Idle.png"; string sRedCrossTex = execPath + "\\Plus_numeric.png"; scFS = new FileStream(scBGTex, FileMode.Open); MokujinFS = new FileStream(mokujunTex, FileMode.Open); RedCrossFS = new FileStream(sRedCrossTex, FileMode.Open); m_ScBGTex = Texture2D.FromStream(GraphicsDevice, scFS); m_MokujinSpTex = Texture2D.FromStream(GraphicsDevice, MokujinFS); m_RedCrossTex = Texture2D.FromStream(GraphicsDevice, RedCrossFS); //設定木頭人的preview (定值) mokujinSpriteAP = new AnimationProperty(m_MokujinSpTex); setupMoKuJunAP(); //設定預覽用Sprite previewSpriteAP = new AnimationProperty(null); previewSpriteAP.m_position = StandLocation; //位置一開始是固定的 previewSpriteAP.m_pivot = new Vector2(previewSpriteAP.m_FrameWidth / 2, previewSpriteAP.m_FrameHeight); _basicEffect = new StockEffects.SpriteEffect(GraphicsDevice); ColorTransformEffect = new StockEffects.SpriteEffect_Colorized(GraphicsDevice); Debug.WriteLine("ColorTransformEffect" + ColorTransformEffect.Name); //啟動重繪 ReDrawThread = new Thread(() => { this.update(); }); ReDrawThread.Start(); //載入Shader,呼叫ContentBuilder Build shader //string cTmEffPath = execPath + "\\ColorTransform.fx"; //contentBuilder.Clear(); //contentBuilder.Add(cTmEffPath, "Shader", null, "EffectProcessor"); //string buildError = contentBuilder.Build(); //ColorTransformEffect = contentManager.Load<Effect>("Shader"); }
/// <summary> /// Creates a new SpriteEffect by cloning parameter settings from an existing instance. /// </summary> protected SpriteEffect(SpriteEffect cloneSource) : base(cloneSource) { CacheEffectParameters(); }