Re: I've hit a wall in .NET
If you have several game objects, lets say ObjectOne, ObjectTwo and ObjectThree all of type ObjectType then you could use the following code:
Code:
ObjectType objectName = ObjectOne;
objectName.location = (x,y);
//ObjectOne's location is now (x,y)
objectName = ObjectThree;
objectName.location = (x2,y2);
//ObjectThree's location is now (x2,y2), and ObjectOne's location is still (x,y)
Re: I've hit a wall in .NET
Hmm, I think I see, so by preceding the text "objectName" with the ObjectType, say "PictureBox", the text objectName is recognized as an object, rather than just a variable, in the following lines of code?
EDIT: I must have misunderstood, that did not work.
Re: I've hit a wall in .NET
In my example objectName is a variable of type 'ObjectType', which can refer to an object of that type (ObjectType).
If you wanted to change a picturebox's location (a different picturebox each time) you'd do something like this:
Code:
PictureBox objectName = PicBoxOne; //Declare the variable objectName as a variable of type 'PictureBox', with an initial value of PicBoxOne (so objectName now references PicBoxOne)
objectName.location = (x,y); //Since objectName references PicBoxOne this line effects PicBoxOne
//PicBoxOne's location is now (x,y)
objectName = PicBoxThree; //Set the variable objectName to reference PicBoxThree
objectName.location = (x2,y2); //Since objectName now references PicBoxThree this line effects PicBoxThree
//PicBoxThree's location is now (x2,y2), and PicBoxOne's location is still (x,y)
I would give you a complete example, but i only have C# installed.