Flash Lite 1.1
Contents |
You want to put graphics into your game, but the graphics would be too large for device to render. But, these graphics make game very heavy and run slow on devices. Then, what to do?
Make a single graphic reuse it and duplicate the graphics to make a big scene.
You can see that all boxes are 16x16. And all graphic boxes are same as 2,4,8 are all same graphics. But make a big picture
You want to reuse the graphics in different area of your game canvas. You have created the tiles.
You can also replace the graphics of your game. You don't have to redraw it again.
You can just replace it. Also insert new graphics box in game.
You got all tile boxes axis, point and tile numbers
Make as a vector graphic, not raster graphic because vector graphics are render fast then raster graphics on device. Use raster or vector graphics it depends on the situation or device.
Create a movie and give instance name "tile"
And create a movie and write a Frame code.
You want to draw a one graphic tile around the canvas like a boundary.
First, draw form top Top Left is 0 and Right left corner 176.
for (p=0; p<=176; p+ =16){
//16 is box size
a++
//a++ is increment of duplicate.
duplicateMovieClip("tile", "tile_a",a);
//tile_a is name A unique identifier for the duplicated movie clip.
//a is depth. A unique depth level for the duplicated movie clip. The depth level indicates a stacking order for duplicated movie clips. It is same as stacking order of layer in the timeline.*/
/:p=p;
tellTarget("tile"){
_x=164;
//Draw tile in X axis
_y=0
}
Same as for other side.
//Top
for (p=0; p<=176; p += 16) {
a++;
duplicateMovieClip("/tile", "tile_a", a);
/:p = p;
tellTarget ("/tile") {
_x = /:p;
_y = 0;
}
}
//Right
for (p=0; p<=176; p += 16) {
a++;
duplicateMovieClip("/tile", "tile_a", a);
/:p = p;
tellTarget ("/tile") {
_x = 164;
_y = /:p;
}
}
//Left
for (p=0; p<=176; p += 16) {
a++;
duplicateMovieClip("/tile", "tile_a", a);
/:p = p;
tellTarget ("/tile") {
_x = 0;
_y = /:p;
}
}
//Bottom
for (p=0; p<=176; p += 16) {
a++;
duplicateMovieClip("/tile", "tile_a", a);
/:p = p;
tellTarget ("/tile") {
_x = /:p;
_y = 192;
}
}
you can download an example with source code here: [Dynamically.zip]
--Narender Raul
No related wiki articles found