GEN002 Text Effects


This example builds on the "Hello World" example. The program attached below shows how to do some special effects on the text. The text is made to spin and shrink (grow smaller).


' Set the text to twice normal size
GenSetTextScale text, 2.0

' Give the text a 45 degree per second spin
GenSpinText text, 45

' Make the text grow smaller over 4 secs
GenGrowText text, 0.1, 4000

An event sub is used to detect when the text has shrunk to 0.1.


' Set an event sub to trigger when grow smaller completes
SetOnGenTextModifierSub text, growDone()

The event sub then exits the program when the grow event completes. The Type Constants are found in the "Game Engine Constants.inc" file in the global include dir.


Sub growDone(text, type)
  if type = Mod_Grow_Complete then
    exit
  endif
End Sub

You should take advantage of the Event Subs whenever possible. Event subs offer a tremendous speed advantage over looping and polling for an event. The main loop of the best game programs will look something like this.


' Loop until the growDone() sub is triggered
do
  wait 1000
loop

Download Source




Game Engine Overview


Game Engine Tutorial


GenSetTextScale


GenSpinText


GenGrowText


GenFadeText


SetOnGenTextModifierSub


Event Triggered Subs






Become a Patron