Table Of Contents
The following is a complete script for programming a Image graphic. When animated, it makes the image move around in a circle. Remember to set the Execute During Animation Program state if you animate a graphic.
/* Declarations */
double cos(double a);
double sin(double a);
@@class() Image:Object
@@method(public, class) (id)alloc;
@@method(public, instance) (id)init;
@@method(public, instance) (unsigned)animationCount;
@@method(public, instance) (void)moveCenterToXValue:(double)xValue yValue:(double)yValue;
@@method(public, instance) (void)sizeToCenteredWidth:(double)width height:(double)height;
@@method(public, instance) (void)release;
@@end
/* Execution block */
{
id myImage;
int ii;
unsigned animationCount;
double xValue, yValue;
myImage = [[Image alloc] init];
animationCount = [myImage animationCount];
red = (animationCount % 10) / 10.0;
green = (animationCount % 20) / 20.0;
xValue = 250.0 + 100.0 * cos(animationCount/20.0);
yValue = 250.0 + 100.0 * sin(animationCount/20.0);
[myImage moveCenterToXValue:xValue yValue:yValue];
[myImage release];
}
|
The general API is define in the section Graphic.