Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Programming Problems
#9
I suggest you learn to program in general before trying to learn game programming. Your problems are stemming from a lack of understanding of C#.

Quote:
Code:
//When the scale is modified through he property, the Size of the
        //sprite is recalculated with the new scale applied.
        public float Scale(KeyboardState aCurrentKeyboardState)
        {
            get { return mScale; }
            set
            {
                mScale = value;

            if (aCurrentKeyboardState.IsKeyDown(Keys.RightShift) == true)                        
            
            {            
                //Recalculate the Size of the Sprite with the new scale
                Size = new Rectangle(92, 45, (int)(Source.Width * Scale), (int)(Source.Height * Scale));
            }
                

                else
            {                                
                //Recalculate the Size of the Sprite with the new scale
                Size = new Rectangle(0, 0, (int)(Source.Width * Scale), (int)(Source.Height * Scale));
            }
                      
        }
        }

In C#, properties cannot take parameters like aCurrentKeyboardState. If you want to be able to get and set something but want the set to take parameters, you could have two methods, GetScale() and SetScale(KeyboardState keyboardState).


Quote:That kind of error is a reason not to make the variable and class name the same - the compiler has to figure out which one you mean from context, and it'll be that much harder to locate errors when they occur, cause you won't know which to search forr.

It's quite common in C# to name a property the same as the class it returns. It doesn't make it any harder to locate errors and it's much better than naming your property TheThing instead of Thing just to avoid that.
Reply


Messages In This Thread
Programming Problems - by Haseo - 2011-07-30, 06:47 AM
Programming Problems - by Unauthorized Intruder - 2011-07-30, 07:59 AM
Programming Problems - by Haseo - 2011-07-30, 08:22 AM
Programming Problems - by Unauthorized Intruder - 2011-07-30, 09:03 AM
Programming Problems - by Haseo - 2011-07-30, 09:19 AM
Programming Problems - by Unauthorized Intruder - 2011-07-30, 10:29 AM
Programming Problems - by Stereo - 2011-07-31, 06:53 AM
Programming Problems - by Haseo - 2011-07-31, 07:29 AM
Programming Problems - by Spaz - 2011-07-31, 03:17 PM

Forum Jump:


Users browsing this thread: 2 Guest(s)