3 Demonstration of using different timelines (sprites)
7 * rfxswf uses a flat tag list
8 All sprite tags between ST_DEFINESPRITE and ST_END
9 will be packed into the data of the ST_DEFINESPRITE
10 by the output routines
12 * make sure, that all defining tags are placed
13 outside the sub-timelines (i.e. before ST_DEFINESPRITE)
15 * framerate is global (sad but true!)
17 Part of the swftools package.
19 Copyright (c) 2001 Rainer Böhme <rfxswf@reflex-studio.de>
21 This file is distributed under the GPL, see file COPYING for details
28 #include "../rfxswf.h"
31 RGBA rgba(U8 r,U8 g,U8 b,U8 a)
32 { RGBA c; c.r = r; c.g = g; c.b = b; c.a = a;
39 #define GET_ID (last_id++)
40 #define GET_DEPTH (last_depth++)
42 int main(int argc, char ** argv)
59 last_id = last_depth = 1;
61 memset(&swf,0x00,sizeof(SWF));
64 swf.frameRate = 0x1000;
65 swf.movieSize.xmax = width*20;
66 swf.movieSize.ymax = height*20;
69 t = swf.firstTag = swf_InsertTag(NULL,ST_SETBACKGROUNDCOLOR);
71 rgb.r = rgb.g = rgb.b = rgb.a = 0xff;
74 t = swf_InsertTag(t,ST_DEFINESHAPE);
78 ls = swf_ShapeAddLineStyle(s,40,&rgb);
81 swf_SetU16(t,id_circle);
89 swf_SetShapeHeader(t,s);
90 swf_ShapeSetAll(t,s,0,0,ls,0,0);
91 swf_ShapeSetCircle(t,s,width/2,height/2,width/2,height/2);
96 t = swf_InsertTag(t,ST_DEFINESPRITE);
99 swf_SetU16(t,id_sprite);
100 swf_SetU16(t,32); // frame count
102 for (i=0;i<32;i++) // 32 frames
104 swf_GetMatrix(NULL,&m);
105 m.tx = width*2+(int)((float)width*2*sin((float)i/16*3.14152));
106 m.ty = width*2+(int)((float)height*2*cos((float)i/16*3.14152));
107 t = swf_InsertTag(t,ST_PLACEOBJECT2);
108 swf_ObjectPlace(t,(i==0)?id_circle:0,1,&m,NULL,NULL);
109 t = swf_InsertTag(t,ST_SHOWFRAME);
112 t = swf_InsertTag(t,ST_END);
114 // SPRITE #2 TIMELINE
116 t = swf_InsertTag(t,ST_DEFINESPRITE);
119 swf_SetU16(t,id_sprite2);
120 swf_SetU16(t,80); // frame count
122 for (i=0;i<80;i++) // 80 frames
124 swf_GetMatrix(NULL,&m);
125 m.tx = width*4+(int)((float)width*4*sin((float)i/40*3.14152));
126 m.ty = width*4+(int)((float)height*4*cos((float)i/40*3.14152));
127 t = swf_InsertTag(t,ST_PLACEOBJECT2);
128 swf_ObjectPlace(t,(i==0)?id_sprite:0,1,&m,NULL,NULL);
132 t = swf_InsertTag(t,ST_PLACEOBJECT2);
133 swf_ObjectPlace(t,(i==0)?id_sprite:0,2,&m,NULL,NULL);
134 t = swf_InsertTag(t,ST_SHOWFRAME);
137 t = swf_InsertTag(t,ST_END);
139 // MAIN MOVIE TIMELINE
141 t = swf_InsertTag(t,ST_PLACEOBJECT2);
143 swf_ObjectPlace(t,id_sprite2,1,NULL,NULL,NULL);
145 t = swf_InsertTag(t,ST_SHOWFRAME); // just one frame
147 t = swf_InsertTag(t,ST_END);
149 // swf_WriteCGI(&swf);
151 f = open("sprites.swf",O_RDWR|O_CREAT|O_TRUNC,0644);
152 if FAILED(swf_WriteSWF(f,&swf)) fprintf(stderr,"WriteSWF() failed.\n");
158 system("start ..\\sprites.swf");