Small library and example code to create text effects in DragonRuby
Preferred install is via DragonRuby builtin download_stb_rb
First, download the lib using the above method, in the DragonRuby Console:
$gtk.download_stb_rb "https://github.com/owenbutler/dr-text-effects/blob/main/app/text_effect.rb"
By default, this will download the lib to owenbutler/dr-text-effects/text_effect.rb
Include the following in your main.rb
:
require 'owenbutler/dr-text-effects/text_effect.rb'
For more control over where the lib is downloaded, see the docs for download_stb_rb
Minimal example:
require 'owenbutler/dr-text-effects/text_effect.rb'
def tick args
if args.tick_count == 0
args.state.wavy = WaveHorizontal.new( {
x: 150, y: 300, text: "The quick brown fox", size_enum: 30,
})
end
args.outputs.sprites << args.state.wavy.render
end
The following effects are supported:
- WaveHorizontal
- WaveVertical
- SlideHorizontal
- SlideVertical
example.mp4
The example code used to create the effects above can be found in main.rb
By default, slide effects will autoplay. If you'd rather control when things play, pass in autoplay: false
and start the animation with .play!
require 'owenbutler/dr-text-effects/text_effect.rb'
def tick args
if args.tick_count == 0
args.state.slide = SlideHorizontal.new( {
x: 150, y: 300, text: "The quick brown fox", size_enum: 30,
}, autoplay: false )
end
args.outputs.sprites << args.state.slide.render
if args.inputs.keyboard.key_up.p
args.state.slide.play!
end
end