Animation Tutorial
Lesson 2. Animating the Airplane
-
We will now adjust the airplane and smoke images so that the plane moves
across the screen from left to right. Ensure that UltraKiss is showing
the main logo screen. Close any existing data set.
-
Use File-Open to load the configuration file
CNF1.cnf from the Tutorial/Kisimi directory or the directory you
created in lesson 1. This will load the data set that you created.
-
Use View-Active Configuration to open the text
editor for the current configuration file. When the set loads we want to
set up our airplane object so the smoke images are initially invisible.
The only visible image in our airplane object group will be the actual
airplane. The initialize() event can be used for this purpose.
-
Position the cursor at the end of the file and add the following lines:
;@EventHandler
;@initialize()
;@ unmap("smoke1.cel") unmap("smoke2.cel")
Note: If you copy and paste these lines from the help
documentation into your configuration file you must ensure that the semicolon
and at-sign combination appears at the beginning of every line.
The EventHandler statement begins the FKiSS event section. All commands
except EventHandler must be written with lower case letters. The
initialize() event is fired whenever a new data set is loaded. The
unmap() commands explicitly set the named smoke images as invisible.
-
Animation is performed with a combination of timer() actions and alarm()
events. A timer fires at a predefined time and causes an alarm() event to
be executed. The alarm() code performs the animation work. We use
the begin() event to set our first timer. The begin() event happens after
initialize() and just before the loaded data set becomes visible on the
screen. Add the following lines at the end of the configuration file:
;@begin()
;@ timer(1,1000)
The timer action will cause alarm(1) to fire 1000 milliseconds after the data
set starts.
-
We must now define alarm(1). Every time the alarm is executed we will
move the airplane object 9 pixels to the right and show the first puffing
smoke. Add the following lines to the end of the configuration file.
;@alarm(1)
;@ map("smoke1.cel") move(#1,9,0) timer(2,100)
In 100 milliseconds we fire alarm(2). Alarm(2) turns off the first
puff of smoke and turns on the second. Add the following lines to the end
of the configuration file.
;@alarm(2)
;@ unmap("smoke1.cel") map("smoke2.cel") timer(3,100)
In 100 milliseconds we fire alarm(3). Alarm(3) turns off the
second puff of smoke and repeats the animation sequence by rescheduling
alarm(1) to fire in 250 milliseconds. Add the following lines to the end
of the configuration file.
;@alarm(3)
;@ unmap("smoke2.cel") timer(1,250)
The sequence of alarm(1), alarm(2) and alarm(3) repeats over and over
again. The repetition causes the airplane to move slowly across the
screen from left to right.
-
Use the File-Exit command in the text editor to
apply your changes. If you happened to have made a typing mistake you
will see an error when the changes are applied. If this occurs, re-edit
the configuration file to correct any mistakes. If there are no errors
the data set should reload and open to page 0 and the airplane should start to
move across the screen.
-
Use File-Save As to save your work. This
time change the name to CNF2.cnf . The new
configuration file with the event code will be saved in the same directory as
the original CNF1.cnf file.
-
Use View-Restart command to commit your changes
and reload the data set.
-
To check your work use File-Open to load the
configuration file CNF2.cnf from your
directory. If you want you can pick up and move the airplane around as
required. You may notice that the airplane tends to flit away from the
mouse as it moves. This happens because the animation movements are
conflicting with your mouse drags. You can prevent this from happening by
turning off FKiSS object moves on mouse controlled objects. This option
is found in the Tools-Options-Compatibility tab.
The View-Reset command will restore the objects to
their original positions.
Next Document: Animation Lesson 3
Prior Document: Animation Lesson 1
Copyright (c) 2002-2005 WSM Information Systems Inc.