Hi all. This is the first time I've registered to a programming forum since usually I rely on searching the internet, but the following problem seems a bit complicated. Appologies if my noobishness makes you hurl
Anyways, I'm currently writing a game in XNA. As part of it I've got a base class for all of the movable objects in my game and have derived a player class which is used to create all of the object classes for players. As part of that I've added a Update class with the intention of calling the other Update class in the base class. This currently looks like this;
Now there's a few problems with this. In my main program I've created an array of ActorBase objects with the intention of 1: Substantiating all of my player objects in it and 2: Adding further NPC objects which will also derive from ActorBase. Insofar as my knowledge of programming goes this is perfectly valid, and the compiler doesn't throw me an error when I do this so I assume I'm on the right track. At any rate, my program doesn't want to call the new Update function of the Player class. This is what I've got (a few other bits of code are also present but I won't put them here for the sake of clarity);
ActorBase class - protected virtual void Update()
Player class - public new void Update()
Compiler error happens with the Update function, claiming that it can't access it. This makes sense if it's calling the ActorBase Update function but given that I initialized it as a Player class, shouldn't it call that Update function instead? Also for future reference, when I'm using foreach loops to call individual objects in the array, is it valid to refer to say foreach (Player player in obj)?
obj = new Player;
obj = new Player(ConstructorStuff);
Thanks in advance for any help!