Stencyl attributes: basic concepts & mechanics


  • Posts: 42
Could one of the more experienced users write a tutorial that covers the basics of attributes?
I understand the concept behind attributes, but I don't know how to make them work.

Like, if I create a number attribute called cannonLength, how can I use my new blue tag to actually mean "this is the length of the cannon" (as opposed to meaning "this is the speed of the projectile", or "this is the amount of projectiles fired", etc.)?


  • Posts: 316
it can be done in 2 ways.
Way 1:
Let's say we want to store cannonLength from a scene.
Drag or put your cannon actor into scene.
Now create cannonLength number attribute from that scene Events, click Events tab create cannonLength number attributes & go through Palette
1. Attributes->setter->cannonLength  <---- Drag it into a When Creating.
2. Actor->Properties->width of actor  <---- Drag it onto 'set cannonLength to'
3. Now click Actor of recent dragged 'width of actor' & choose cannon. that's it.
Now you have cannonWidth.

Way 2:
This time you don't have to create any attributes. without attributes you could use length( Width, Height ) of cannon. Open your cannon Actor,
Click Events tab, Actor->Properties->width of self <--- this will let you know what is the width of cannon. Same for Height.
that's all.

« Last Edit: January 13, 2014, 04:03:51 pm by sandsoftimer »
iOS ->          

Android ->
iOS -> Bubble Tapping
 Android -> Bubble Tapping

Taki Tanker

  • Posts: 24

Lets  say that we want to create an attribute that store the time remaining before the player dies..
We'll call it TIME_REMAININg(attribute), TIME_REMAININg is a variable of type number that can store any number.

lets give it an initial number (a small programing is used here for explanation)
   TIME_REMAININg = 5      (initialization)
   Every 1 (second) do      (Loop)

This way every 1 second the TIME_REMAININg is gona decreases by 1

   TIME_REMAINING = 4 after 1 sec
        TIME_REMAINING = 3 After 2 sec
        TIME_REMAINING = 0 after 5 sec
        TIME_REMAINING = -1 after 6 sec and so on.                 

Now in stencyl,
lets implement the above, kill the player after 5 sec (of course u need to make an attribute of type number and name it TIME_REMAININg)

1) When create

2) Do every 1 Sec
        If  TIME_REMAININg =0
              Kill self
             set TIME_REMAININg = TIME_REMAININg - 1

This is a small use of an attribute as a Timer in game
PS. This behavior should b attached to the player.

I hope this will clear things out.

« Last Edit: January 13, 2014, 04:52:26 pm by Taki Tanker »


  • Posts: 89
An attribute in Stencyl is another way to say Variable. It is something that stores a value.

Using your cannonLength as an example, when you created the attribute it's like taking a notebook and writing the word cannonLength on the front. It doesn't do anything yet.

In one of your events, you have to assign the value to it.

Set-cannonLength to 100

or 10    or 50,000 or whatever you want the length of the Cannon to be. Setting the value is like writing in the notebook.


  • Posts: 42
2. Actor->Properties->width of actor  <---- Drag it onto 'set cannonLength to'
My fault -- I should have mentioned I'm still using Stencyl 2.2. It looks like the actor's width is found in Collisions in this version, & there doesn't seem to be anything to drag. Thanks for the input.

Your second method gives me some ideas. Combined, the 3 answers I received should help me sort this out....I'm probably just overthinking it.