7.2.0pre003
Pre-releaseThis is a beta version and should not be used in production.
Typewriter behaviour is now controlled using a "typist". A typist is a unique (non-cached) machine that controls how your text is revealed and how events are executed as text is revealed. For example, you should create one typist per textbox. Typists are created by calling scribble_typist()
and are garbage collected automatically. Typists can be used with a text element by targetting the typist with the text element's .draw()
method. For example:
typist = scribble_typist();
typist.in(1, 0);
///Draw
scribble("Here's some typewriter text!").draw(x, y, typist);
Note that we called the .in()
method. This is analogous to the old .typewriter_in()
method that was available on text elements in previous versions. Here's a list of methods for typists, and they follow the same basic rules as the old typewriter functions.
.reset()
.in(speed, smoothness)
.out(speed, smoothness, [backwards])
.skip()
.sound(soundArray, overlapMS, pitchMin, pitchMax)
.sound_per_char(soundArray, pitchMin, pitchMax)
.function_per_char(function)
.pause()
.unpause()
.ease(easeMethod, dX, dY, xScale, yScale, rotation, alphaDuration)
.associate(textElement) <-- You'll probably never need to use this
A typist should only be used to control text reveal for one text element at a time. Changing text element, or changing the page for that text element, will cause the typist to automatically be reset.
Typists are automatically associated with a text element when targetted using that text element's .draw()
method. If you want to manually associate a typist with a text element you'll need to use .associate()
method (on the typist).
Additionally, two methods have been added to text elements. .reveal()
sets how many characters are visible in the text element (including spaces), and .reveal_get()
returns that value. Using a typist will override any value set with .reveal()
. Revealling characters using .reveal()
will also not execute any events whatsoever - you'll need to use a typist for that.
Finally, in light of above, .typewriter*()
methods have been deprecated for text elements returned by scribble()
. You will get a warning when trying to use these functions. If you don't want to transition across to using the new typist system then set SCRIBBLE_WARNING_LEGACY_TYPEWRITER
to false
. Existing behaviour should be unaffected if you use legacy methods, but try to migrate your code if you can as the old featureset will be fully removed in the next major version (later this year probably).