What is best performance wise regarding interactions?

You need help? It's here!
Post Reply
LegendaryAgent
Member
Posts: 80
Joined: Thu 29 Sep , 2011 12:26 am
Contact:

What is best performance wise regarding interactions?

Post by LegendaryAgent » 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!

iZumo
Disappeared Administrator
Posts: 4196
Joined: Fri 19 Mar , 2010 1:21 am
Location: Earth
Contact:

Re: What is best performance wise regarding interactions?

Post by iZumo » Tue 15 Nov , 2011 10:10 pm

When dealing with interactions, you will always want to reduce their number to minimum, so if there is a need for an interaction, use just one "smarter", instead of a lot "dummier". However, if you just want to draw on HUD, use HUDOverlay.

LegendaryAgent
Member
Posts: 80
Joined: Thu 29 Sep , 2011 12:26 am
Contact:

Re: What is best performance wise regarding interactions?

Post by LegendaryAgent » Tue 15 Nov , 2011 11:21 pm

Izumo_CZ wrote:When dealing with interactions, you will always want to reduce their number to minimum, so if there is a need for an interaction, use just one "smarter", instead of a lot "dummier". However, if you just want to draw on HUD, use HUDOverlay.
ok so this means i should always choose more ifs in postrender instead of many interactions with easier postrenders, correct?
EDIT: btw i dont just need a simple display, its has to do with strings and keypress events aswell.

Post Reply

Who is online

Users browsing this forum: No registered users and 22 guests