2 * Copyright (C) 2005, 2006, 2009, 2010, 2011 Free Software Foundation, Inc.
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 3 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20 * Zou Lunkai, zoulunkai@gmail.com
22 * Test for tag PlaceObject2 and also sprite_instance::advance_sprite(float delta_time)
24 * Normally, you will see the both the red square and black square
25 * again and again while looping back
27 * run as ./place_and_remove_object_test
34 #include "ming_utils.h"
36 #define OUTPUT_VERSION 6
37 #define OUTPUT_FILENAME "place_and_remove_object_test.swf"
43 main(int argc
, char** argv
)
46 SWFMovieClip dejagnuclip
;
49 const char *srcdir
=".";
54 //fprintf(stderr, "Usage: %s <mediadir>\n", argv[0]);
59 mo
= newSWFMovieWithVersion(OUTPUT_VERSION
);
60 SWFMovie_setDimension(mo
, 800, 600);
61 SWFMovie_setRate (mo
, 1.0);
63 dejagnuclip
= get_dejagnu_clip((SWFBlock
)get_default_font(srcdir
), 10, 0, 0, 800, 600);
64 SWFMovie_add(mo
, (SWFBlock
)dejagnuclip
);
65 //SWFMovie_nextFrame(mo);
68 sh1
= make_fill_square (0, 300, 60, 60, 255, 0, 0, 255, 0, 0);
69 sh2
= make_fill_square (330, 300, 60, 60, 255, 0, 0, 0, 0, 0);
73 it
= SWFMovie_add(mo
, (SWFBlock
)sh1
); //add a red square to the 1st frame at depth 3
74 SWFDisplayItem_setDepth(it
, 3);
75 SWFDisplayItem_setName(it
, "sh1");
76 check(mo
, "_root.sh1 != undefined");
77 check_equals(mo
, "_root.sh2", "undefined");
78 SWFMovie_nextFrame(mo
);
80 SWFMovie_remove(mo
, it
); //remove the red square at the 2nd frame
81 check_equals(mo
, "_root.sh1", "undefined");
82 check_equals(mo
, "_root.sh2", "undefined");
83 SWFMovie_nextFrame(mo
);
85 it
= SWFMovie_add(mo
, (SWFBlock
)sh2
); //add a black square to the 3rd frame at depth 3
86 SWFDisplayItem_setDepth(it
, 3);
87 SWFDisplayItem_setName(it
, "sh2");
88 check_equals(mo
, "_root.sh1", "undefined");
89 check(mo
, "_root.sh2 != undefined");
90 add_actions(mo
, "if ( ++counter > 1 ) { _root.totals(); stop(); }");
91 SWFMovie_nextFrame(mo
);
94 puts("Saving " OUTPUT_FILENAME
);
95 SWFMovie_save(mo
, OUTPUT_FILENAME
);