What is best performance wise regarding interactions?
Posted: Tue 15 Nov , 2011 9:47 pm
Hey guys, im right now trying to get the hang on for interactions, and right now im in a delicate situation where could shape the way i code interactions to work in the game, ive got a simple question, its performance wise:
What is best for performance, i either make 1 interaction with many sprites drawn (for example):
Example 1 //1 Interaction is spawned, and it will be used to display various hud elements of different inventories inside the game
{
class Interaction1 Extends Interaction;
If inventoryitem1!=None
draw a 3 sprites, and 2 texts for inventoryitem1
If inventoryItem2!=None
draw another 3 sprites and 2 texts for inventoryitem2
If InventoryItem3
Draw another 3 sprites and 2 texts for inventoryitem3
If InventoryItem4!=None
Draw another 3 sprites and 2 texts for inventoryitem4
WHEN NONE OF THE INVENTORY ITEMS ARE AVAILABLE THE INTERACTIONDESTROYED
}
Example 2 // 1 Interaction is spawned per Inventory, each interaction will only display its own inventory hud instead of having 1 to control the display of all
class Interaction1 extends Interaction;
draw 3 sprites and 2 texts for inventoryitem1
When inventoryitem1 no longer exists, it gets deleted.
class Interaction2 extends Interaction;
draw 3 sprites and 2 texts for inventoryitem2
When inventoryitem2 no longer exists, it gets deleted.
class Interaction3 extends Interaction;
draw 3 sprites and 2 texts for inventoryitem3
When inventoryitem3 no longer exists, it gets deleted.
class Interaction4 extends Interaction;
draw 3 sprites and 2 texts for inventoryitem4
When inventoryitem4 no longer exists, it gets deleted.
Please Note the first example does the if checks in PostRender(), the creating of the interaction & destroy process is quite rare, it only happens when player spawns and player "dies".
I like the idea of example 2, its organized better and it gives me the impression of a better performance, however, im not sure, and it might end up with a horrible performance impact instead, the first interaction example is still a question mark for me because those ifs are getting called in postrender.
What do u guys think? im kinda stuck in here xD
Thanks in advance!
What is best for performance, i either make 1 interaction with many sprites drawn (for example):
Example 1 //1 Interaction is spawned, and it will be used to display various hud elements of different inventories inside the game
{
class Interaction1 Extends Interaction;
If inventoryitem1!=None
draw a 3 sprites, and 2 texts for inventoryitem1
If inventoryItem2!=None
draw another 3 sprites and 2 texts for inventoryitem2
If InventoryItem3
Draw another 3 sprites and 2 texts for inventoryitem3
If InventoryItem4!=None
Draw another 3 sprites and 2 texts for inventoryitem4
WHEN NONE OF THE INVENTORY ITEMS ARE AVAILABLE THE INTERACTIONDESTROYED
}
Example 2 // 1 Interaction is spawned per Inventory, each interaction will only display its own inventory hud instead of having 1 to control the display of all
class Interaction1 extends Interaction;
draw 3 sprites and 2 texts for inventoryitem1
When inventoryitem1 no longer exists, it gets deleted.
class Interaction2 extends Interaction;
draw 3 sprites and 2 texts for inventoryitem2
When inventoryitem2 no longer exists, it gets deleted.
class Interaction3 extends Interaction;
draw 3 sprites and 2 texts for inventoryitem3
When inventoryitem3 no longer exists, it gets deleted.
class Interaction4 extends Interaction;
draw 3 sprites and 2 texts for inventoryitem4
When inventoryitem4 no longer exists, it gets deleted.
Please Note the first example does the if checks in PostRender(), the creating of the interaction & destroy process is quite rare, it only happens when player spawns and player "dies".
I like the idea of example 2, its organized better and it gives me the impression of a better performance, however, im not sure, and it might end up with a horrible performance impact instead, the first interaction example is still a question mark for me because those ifs are getting called in postrender.
What do u guys think? im kinda stuck in here xD
Thanks in advance!