ID:161178
 
Heres the problem.
My on-screen text system uses alot of CPU as it has to constantly create and delete objects for the letters.

Best way to handle this would be to have a preloaded cache of objects to use, only problem with that is that they cant be displayed to multiple players at one time because theyd be changing around on the player's screens. Another option would be to have a cache for each player, but that would be a gigantic waste of objects.

SO! best solution I can come up with at the moment is to make a dynamic reuse system. Meaning during a chat session it re-uses the letters that are already on the screen instead of deleting and re-creating between every popup window, only creating new letter objects if not enough were present in any of the previous windows. At the end of each series of messages it would delete all objects and then create new ones when you start talking to the next NPC or whatever triggers the next on-screen popup.

Anyone have a better idea?

Creating and deleting objs really shouldn't be that costly to your game. I would suggest looking deeper into the problem because creation and deletion of objs, while not free, is not inherently stressful either.

Lummox JR
In response to Lummox JR (#1)
Lummox JR wrote:
Creating and deleting objs really shouldn't be that costly to your game. I would suggest looking deeper into the problem because creation and deletion of objs, while not free, is not inherently stressful either.

Updating the HUD by creating/deleting new objects was one of the most CPU intensive things in all of my games according to the fancyfull profiler. Ive found an easy way around it by simply updating existing objects, but when there needs to be 100-500 letters on a screen at a time; I cant just have them constantly sitting around, especialy since they arent always in use
In response to Falacy (#2)
Altering stuff with client.screen can get intensive, yea. The simplest fix for this is to pool from a common resource of HUD object.
In response to Popisfizzy (#3)
Popisfizzy wrote:
Altering stuff with client.screen can get intensive, yea. The simplest fix for this is to pool from a common resource of HUD object.

It cant be altering, because altering is what I do now and it uses almost no CPU. Possibly adding/removing the objects to and from the screen is what was using the CPU. The point is though, I cant just leave 500 objects sitting around in every players screen.