updating components

Started by
0 comments, last by _walrus 21 years, 9 months ago
Hi, Suppose i want to update a bunch instances. These instances contain children which themselves are to be updated. (a tree structure can not be guarenteed...several instance may be referencing the same instance) I'm just writing a 2d gui menu library using opengl and i want to resize all components by a scalar value. But multiple menu systems can reference the same instance. i.e., the main menu has an 'exit to windows' button and the in-game menu also has this 'exit to windows' button. I guess i could traverse the structure and create an array with out duplicates and then update each component of this list (but this is O(n^2) and sloppy). i'm just wondering what the best way to updated all the components only once is. Thanks [edited by - _walrus on June 27, 2002 10:21:53 PM]
Advertisement
One possible solution would be to keep track of what iteration you are currently in. For example, first game loop you are iteration 0, then you increment by 1 each game loop. Each instance could have a ''last time updated'' variable that it checks before performing an update. If the last iteration updated equals the current iteration, then don''t update the instance because you already have this game loop.

A slight variation on this would be to just have your ''iteration'' count alternate between 0 and 1 each game loop if everything always gets updated each loop.

This topic is closed to new replies.

Advertisement