Jump to content
  • Advertisement
Sign in to follow this  

XNA C# Game - Transition problems

This topic is 1815 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hoping someone here can help me out!


I've recently started trying to make my own Tile based game and I'm trying to get screen transitioning working.

In my code i can get the splash screen i have to come up, but then once I press Enter (my key to start transitioning) It's supposed to just fade out and then back into the splash screen presently as it's transition, but it's not doing it.

Instead when i throw a break into the transition method, it's just looping through it forever.

On top of that, I have it setting the alpha for my image to 1.0f when the image class gets called, but somewhere it's changing it to 0.0f and it's failing to transition properly.

I've been staring at my code for a few days now and haven't been able to sort it out.


I'm hoping a fresh pair of eyes can help me figure out what i'm missing.


I've attached my source, it's a VS2012 Project using XNA 4.0


Thanks for anyone who's able to help me with this.


Share this post

Link to post
Share on other sites

It's a little hard to tell , but from a quick play around it doesn't look as if you ever activate your fade effect ( though when I do I then get issues with one of the Images being inactive). There is also seems to be a problem in that you set your alpha value to 0 at the start which means it immediately goes into a Transitioning false state rather then playing through the transition. Setting it to 0.01 gets past that. 

I'll keep having a play and see if I can find anything more.

Share this post

Link to post
Share on other sites

In the xml file i set it to use the fade effect.

<?xml version="1.0" encoding="utf-8" ?>

and in Image.cs I have it set the image alpha to 1.0f.

        public Image()
            Text = string.Empty;
            Effects = string.Empty;
            FontName = "Fonts/Arial";
            Path = string.Empty;
            Position = Vector2.Zero;
            Scale = Vector2.One;
            Alpha = 1.0f;
            SourceRect = Rectangle.Empty;
            _effectList = new Dictionary<string, ImageEffect>();


Share this post

Link to post
Share on other sites

Yup, I saw all that, Just trying again and the key for activating the FadeAffect in LoadContent is Effects/FadeEffect, but the key in the Image is just FadeEffect so that doesn't trigger. updating SplashScreen.xml fixes that. I'm still a bit puzzled by the start and end alpha values for Transition - it seems that after 1 update you have alpha at 0.0 or 1.0 which stops the transition. If you change the start value to say, 0.01 and change the effect key then you'll get the screen fade, though it then NPE's on a load content when it finishes :)

Share this post

Link to post
Share on other sites

Don't think what you're doing is broken at all , and there are  lots of ways to achieve the effect., I think the NPE I got was just maybe an error you hadn't reached yet as the transition hadn't fully occurred. For one of my projects I used a gamestate manager based on one of the MS samples : http://xbox.create.msdn.com/en-US/education/catalog/sample/game_state_management  , (my modified version part of a project at : https://code.google.com/p/xexuxjy-xna-games/source/browse/#svn%2Ftrunk%2FGladius%2FGladius%2Fgamestatemanagement)

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!