Hello, I have a pretty important question about which method is more efficient/optimized/run faster in my app,
First:
Enter scene…
Don’t use functions
-Load up spritesheets, npc data, etc
-Create NPC
-Create NPC
-Create NPC
This option has a lot of repeated code in the create NPC, making it very long…but only loads up spritesheet once.
Second:
Function spawner (params)
- load spritesheet
- npc, monster, etc on params data
- create based on params
- return object
end
Enter scene…
-
create NPC ( Call function spawner, pass in params, get NPC data back)
-
create NPC ( Call function spawner, pass in params, get NPC data back)
-
create NPC ( Call function spawner, pass in params, get NPC data back)
This option uses a lot less code as it gets rid of repeated code, and here is why I ask this question I am calling this function over and over when I want to spawn something/anything and it loads up spritesheet, monster data and spits back monster. I figured loading up the spritesheet data continously on the fly and everything would boggle the system down more?
My spritesheet data uses a lot of sheets and a lot of different sprite angle’s as its already 50+ lines of code just on the spritesheet initalization.
I care more about optimization with less lag, and gain more fps…I care less about readability.
Thanks for your time.