Namespaces
Variants
Actions

How to use tiles in games in Flash Lite 1.1

Jump to: navigation, search
Article Metadata

Code Example
Article
Created: narender_raul (20 Mar 2008)
Last edited: hamishwillee (06 Feb 2012)


Flash Lite 1.1

Contents

Develop game

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.

Tile game


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


You have to draw a rectangle box 16x16.

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.

Write a code

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.

Add this code

//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;
}
}

Download

you can download an example with source code here: Media:Dynamically.zip


--Narender Raul

Comments

Reviewer-approved.png
19 Sep
2009
Article Review by saurabhgo (20090919)

Article explaining the use of same graphics symbol to create the Tile based gaming base.

Creating the applications in FlashLite 1.1 is itself a challenge and hence making the best use of available memory is key to succeful 1.1 application. Duplicating the same symbol will reduce the actual file size and hence more memory will be available at run-time.

Also the code demonstrates the use of FlashLite 1.1 specific coding structures, like using 'telltarget' method.


This article shows the easy way to make games with flash. If you want to creat games in simple way flash is the right choice.The article is well described with picture. Your knowladge and this type of article will duly help you to make different games.


This page was last modified on 6 February 2012, at 05:58.
56 page views in the last 30 days.
Nokia Developer aims to help you create apps and publish them so you can connect with users around the world.

京ICP备05048969号  © Copyright Nokia 2012 All rights reserved