473,385 Members | 1,720 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Inherited properties

Hi guys

I must be missing something fundamental here in my animation prog.

I have a class called Object Manager and in that it holds a List<> of
SceneObjects, on every frame on my animation i update my GameTime which is a
TimeSpan. So inside the object manager i do:

public void GameTime(TimeSpan time)

{

foreach (SceneObject so in _sceneObjList)

{

so.GameTime = time;

}

}

So that all the sceneobjetcs have their internal timers kept in sync. i have
objects that inherit from SceneObject and i use their internal _gameTime
(set above) to get the gametime. But i am noticing that inside the inherited
members gametime seems to get set once and then never gets updated, even
though if i do a check straight after i set game time it is constantly
updating, it seems it is not updating down the chain. Why?
Jun 8 '06 #1
3 1393

Daniel wrote:
Hi guys

I must be missing something fundamental here in my animation prog.

I have a class called Object Manager and in that it holds a List<> of
SceneObjects, on every frame on my animation i update my GameTime which is a
TimeSpan. So inside the object manager i do:

public void GameTime(TimeSpan time)
{
foreach (SceneObject so in _sceneObjList)
{
so.GameTime = time;
}
}

So that all the sceneobjetcs have their internal timers kept in sync. i have
objects that inherit from SceneObject and i use their internal _gameTime
(set above) to get the gametime. But i am noticing that inside the inherited
members gametime seems to get set once and then never gets updated, even
though if i do a check straight after i set game time it is constantly
updating, it seems it is not updating down the chain. Why?


All sounds OK so far. Can you show us the property code for GameTime in
SceneObject (and in a descendant that goes wrong, if it's different)?

--
Larry Lard
Replies to group please

Jun 8 '06 #2
Property code in scene object is:

public TimeSpan GameTime

{

get { return _gameTime; }

set { _gameTime = value; }

}

and inherited class from that uses _gameTime member.

"Larry Lard" <la*******@hotmail.com> wrote in message
news:11**********************@g10g2000cwb.googlegr oups.com...

Daniel wrote:
Hi guys

I must be missing something fundamental here in my animation prog.

I have a class called Object Manager and in that it holds a List<> of
SceneObjects, on every frame on my animation i update my GameTime which
is a
TimeSpan. So inside the object manager i do:

public void GameTime(TimeSpan time)
{
foreach (SceneObject so in _sceneObjList)
{
so.GameTime = time;
}
}

So that all the sceneobjetcs have their internal timers kept in sync. i
have
objects that inherit from SceneObject and i use their internal _gameTime
(set above) to get the gametime. But i am noticing that inside the
inherited
members gametime seems to get set once and then never gets updated, even
though if i do a check straight after i set game time it is constantly
updating, it seems it is not updating down the chain. Why?


All sounds OK so far. Can you show us the property code for GameTime in
SceneObject (and in a descendant that goes wrong, if it's different)?

--
Larry Lard
Replies to group please

Jun 8 '06 #3
Personally, I would strongly advise paking the field private, and having
inherited classes use the property; the JIT will 99% inline this anyway, so
no performance hit - but it could protect you from all manner of issues.

I don't know how this field is read; is it in a loop on a differrent thread?
if so, it could be volatility here? perhaps mark the time as volatile?

Also - that's a lot of dates to constantly have to resync; why not drop the
time onto a class, and have all objects in the animation reference that
class - then you only have to update one time, but all objects can see it
(via the shared reference). Obviously each class then needs space for an
object reference, rather than a datetime - can't remember the sizes of each,
but a few bytes isn't going to be the killer here.

Marc
Jun 8 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: mrVithan | last post by:
I create a user control object and show its properties through a propertygrid object in my application. It is sure that there are 100 hundred of properties inherited from...
5
by: Earl Teigrob | last post by:
Is there a way to rename the public properties of a inherited class? I am inheriting an asp.net control (class) and am adding addtional functionality. (in this case, up to 3 borders on an...
2
by: ad | last post by:
I have a base form, there a textbox on it, I set the textbox to protected. The properties of the textbox can't be modified when I inherited a form from the base form. I want to...
4
by: Dan | last post by:
I have a need to make a set of classes that all share the same public methods, some implementation and some data. So, I made an abstract base (BaseClass) with an interface (IBaseClass) and a...
3
by: Gene Hubert | last post by:
I've got a custom datagrid that inherits from the standard datagrid on a windows form. I expected that since it is an inherited object, protected properties from the standard datagrid would be...
8
by: Spam Trap | last post by:
I am getting strange resizing problems when using an inherited form. Controls are moving themselves seemingly randomly, but reproducibly. "frmBase" is my base class (a windows form), and...
0
by: porter_wss | last post by:
I am a bit confused on serializing objects and inherited objects. What I am trying to accomplish is creating a base object and an inherited object with additional properties. The sender of these...
10
by: Smokey Grindle | last post by:
i want to inherit the list view class, but in the inherited class, hide the Header style property and the view property (basically its a detailed list with always clickable headers) how do I keep...
4
by: EmilH | last post by:
Hi. I couldn't find it in msdn. I have a form AddCategory. Now I need EditCategory form which should look exactlay like AddCategory. I add an inherited form to the project. Now all controls'...
13
by: PragueExpat | last post by:
I (think) that I've come up with a pattern that I haven't seen in any publications so far and I would like some feedback. Basically, I was looking for a way to inherit private functions and I came...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.