-
Notifications
You must be signed in to change notification settings - Fork 90
exercise_2
The second exercise set, goes into the subject of transformations. Among the many properties that are maintained for an object (as you might have noticed in the state-dump from the previous exercise) there are the usual suspects: position, visibility, drawing order, orientation and scale.
Changing these properties are, by default, instantaneous -- the effects will be visible on the next frame. The other option is to specify a deadline and an optional interpolation function that controls how the engine should animate between the current state and the next.
Each video object has transformation chains for common transforms, e.g. move, scale, rotate and blend. Multiple calls with a deadline add to previous ones in the same slot, and are then interpreted in sequence.
The slots are independent so you can say 'move to here in 100 ticks then to this other place for 50 ticks after that while rotating 40 degrees clockwise for 125 ticks'.
The subtasks to go through here are as follows:
Set up a transformation chain where a box moves from 0, 0 to the center of the screen in exactly one second.
Hint 1: Look at the CLOCKRATE global value.
Look for constants with the prefix INTERP (either in the documentation or by dumping the Lua _G table of globals). These can be used as an additional optional argument after the time argument to a transformation.
Create a few boxes and position them side by side. Move them down to the bottom of the screen slowly (100 ticks or so) and set different interpolation functions for each of them.
Create a single colored object and set up a chain of transformations so that one follows the other, i.e. first blend, then move when the blend is completed, then rotate when the motion is completed and finally scaling.
Hint 1: You can either define no-op transforms that consumes time in a slot but perform no real change to its properties, or you can try with tag_image_transform.
Compare nudge_image to move_image and scale_image to resize_image.
Set up a transformation chain where a green box moves between the corners of the screen infinitely.
Hint 1: Look into image_transform_cycle.