State and events
Formo team · 14 October 2016
Hello,
A picture that does not react to anything is a poster. This week: how things in a drawing get to react.
Your own properties
Every shape comes with properties we invented for it: position, size, colour. But your drawing has needs of its own. A game scene has a score. A character has mood. A button has pressed.
So we are building a way to add your own properties to a shape. Give it a name, a type, a starting value, and from then on it behaves like any built-in property: you can type a value, use it inside a formula, or change it over time. Think of it as sticky notes on a shape where you write down what is true about it right now.
A custom property, and a label that follows it.
Events: when something happens
A property tells you how things are. An event says what to do when something happens: a click, a hover, a tick of the clock. You pick the shape, pick the event, and write what should follow — for example, "when clicked, add one to the score".
The events are written right next to the shape they belong to, in a small editor with highlighting and suggestions, so you never need to hunt through the project to find "why did that move?".
Common methods can also be given a name and reused: write "reset the level" once and call it from any event.
Click, add one, label updates.
State and events are the first two legs of something that can behave. We would love to hear what you would make react first.
As always, let us know what you think on our Discord.