Game wide variables and blocks

sketchling

  • Posts: 17
How can I create a variable like a score that is available in all scenes? I am assuming global custom blocks are the way to create universal functions, but im not sure how to 'attatch' a behavior to a whole game or however the thinking goes. Would you have to transfer your settings to each new scene? :-\

Blob

  • *
  • Posts: 722
Game Attributes (which can be found and created in either the Attributes tab in design mode or under Game Settings in the Game center) work just like standard attributes in that their values can be edited in behaviors, but their values stay consistent throughout all scenes, so they're universal. You don't necessarily attach them to the game, they're just always apparent.

~ Blob

Ceric

  • *
  • Posts: 610
The fastest way to transfer all of your settings to a new scene is to copy it and then just edit your scene (i.e. erase the level map in the copy of your scene and draw a new one).

You can duplicate it by right-clicking on a scene and clicking "duplicate." All of your scene's behavior settings will be transferred to the copy.

Also, like Blob said, Game Attributes are the way to maintain variables between scenes.

gigaclon

  • Posts: 163
Global custom blocks are static functions. That means they are apart from any actor and scene and can't access them except by passing them in as arguments.

sketchling

  • Posts: 17
not sure how i missed a game attributes section... i was wondering if i was missing something! Thanks!

gigaclon : My question is more where do you create the block. from what I can see if you create a global custom block and want to edit it, you need to find the behavior you created it in. you can access it as an argument from anywhere, but you can only edit it in that first behavior (that is as far as i can see)... so is it best to make one behaviour with all the global functions you are intending to use, or can you create them outside a behavior somewhere specifically for that kind of thing. Things like distance between objects, angle between, that kinda stuff.  I guess its a bit like a little library of functions.

Anyway, just wondering. I am loving what stencyl can do :)

gigaclon

  • Posts: 163
Yeah i just create a behavior for Utility functions like that