Performance: Game Attribute (purple) Vs Attribute (blue)

RulezTeam

  • *
  • Posts: 319
Hi,

my questions are specific for performance and optimization of a game; so :

- In an always cycle, is preferable to use the blue variable ?
- what the impact of processor and memory between Game Attribute Vs Attribute ?

My impression is that Attribute (blue) is more reliable to use with older smartphone. is this correct ?

Thank you for your reply.

Well, Blue Attributes only affect the actor. (From what i have learned)

And Purple Attributes affect the whole game. 


In my opinion, Blue Attributes & Purple Attributes take about the same amount of power. (Blue Might take a bit less, don't know)

If you want to increase performance, just change {Always} to {Every N Seconds}.
I'm 17 years old, here to help and Entertain. {Also to make fun games}
ADAM: (http://www.stencyl.com/game/play/25588)
Also, if you need help making a platformer, search {Jumper} in Stencyl Forge. This is a player with everything you need in it, that i made. Enjoy!

Alexin

  • *
  • Posts: 3127
1. The usage of global vs regular attributes should NOT be decided on performance, because it doesn't matter to start with. Use global attributes for variables that must persist across scenes and have a meaning in the game as a whole.

2. Global attributes are as good as regular attributes when it comes to performance and memory management. Do NOT even care about such details.

3. Global attributes are as reliable as regular attributes. (Where did that smartphone thing come from?)

4. "Blue" attributes do not "affect" actors only. These are defined at the behavior level, for both Actors and Scenes.

5. Unless you have strong reasons to believe global attributes are impacting your game negatively, which is *very* unlikely, do NOT even think about these details.

6. Using [do every X seconds] does NOT increases performance "automagically".
Many objects in a game need regular updates. Critical objects like bullets and controls benefit from as many updates as they can, while non-critical objects like  a waving flag or other decorations need to be updated only once in a while.
The less there is to be done a single step/frame, the better the game performs.
"Find the fun"
alexin@stencyl.com

Tuo

  • *
  • Posts: 2469
When done in a mass matter, game attributes are indeed slower than normal attributes (at least in 2.2; I saw it firsthand in my "Demo- Off Screen Actors"). That said, if you are using game attributes to that degree, you are very likely using them incorrectly ;).
Don't look to me but rather to the One who is the reason for what I do. :)

If you need help, send me a PM. Even if I haven't been on in the forums in ages, I still receive those messages via email notifications. You can also reply to any of my forum posts, regardless of the age (especially if I created it), and I will likely reply.

If you want to see the programming behind certain types of games, feel free to check out my "Demo-" games on StencylForge (http://community.stencyl.com/index.php/topic,16160.0.html)

Alexin

  • *
  • Posts: 3127
I didn't want to bring that up because I don't want users to worry about the details, but I guess I have no choice now.

Regular attributes (those defined in a behavior) are plain variables. Period.
Global attributes are stored in a associative array and the cost of accessing a single attribute is constant on average (and low).

I said global attributes are as good as the others because they behave similarly in practice. Of course, if you attempt to access a lot of them in a short amount of time, then all those tiny costs sum up to the point of being noticeable. As Tuo correctly said, if you reach that point then you are probably doing something wrong; global attributes are not meant to be used en masse.
"Find the fun"
alexin@stencyl.com