You Are Here:

Community: Blogs

Giorgio Natili's Forum Nokia Blog

Flash Lite 1.1 collisions

gioorgionatili | 02 February, 2008 17:56

Flash Lite 1.1 collisions
A common task you may need when you start to develop a Flash Lite 1.1 arcade game is to check the collision between the sprites on the screen.
If you surf the web you may find tons of way to detect the collision in Flash but in Flash Lite 1.1 you have refer to the old ActionScript 1.0 syntax.
In this post we’ll try to explore the building blocks of detecting collision through a sample in which a character have to get some gift that are attached on the screen in a random way (fig. 1).

fig. 1 
fig. 1

In order to complete this task we need to create a movie clip that contains the function that launches the gift (remember that Flash Lite 1.1 doesn’t support the functions so you store the script you need in a key frame associated to a label), a movie clip that call this function, a movie clip that store the script that moves the gift and that check the collisions and a movie clip used as a character.
The first three movie clips are outside the stage (fig. 2).

fig. 2 
fig. 2

The aim of the “functions” and “loop” movie clips are self explanatory because the first one contains the code that duplicate the “gift” movie clip on the stage

// Duplicate the movieclip
duplicateMovieClip("../gift", "gift_mc" add count, count);
// Control the duplicated movie clip
tellTarget("../gift_mc" add count){ 
 // Set the position of the movieclip
 _x = random(/:_width);
 _y = 0; 
 // Start to move
 gotoAndPlay("moving");
 // Set the max value for the y
 set("ymax", /:screenHeight); 
}

and the second one the call to this script at the end of its timeline.
Let’s take a look inside the gift movie clip.
Organize your timeline in order to have a a key frame with the label “moving” and a key frame with the label “removing” (fig. 4).

fig. 4 
fig. 4

The “moving” key frame modifies the value of the _y property and launches a loop inside which you check if the movie clip has reached an _y that is outside the screen or if it is colliding with the character on the stage

// Check if the movie clip is get from the sprite
if(_y + _height > eval("../sprite_mc")._y ){
 if(_x > eval("../sprite_mc")._x && _x < eval("../sprite_mc")._x + eval("../sprite_mc")._width){ 
  tellTarget("../sprite_mc"){  
   gotoAndPlay("getIt");   
  }  
  removeMovieClip("");    
 }
}
// Check if the gift is outside the screen
if (_y + _height >= ymax) { 
  isLooping = false; 
}else{ 
 isLooping = true; 
}

the “removing” key frame changes the graphic of the movie clip and at the end of its timeline removes the movie clip from the stage

removeMovieClip("");

I’m pretty sure that everybody knows how to move the main character on the stage so I’ll not explain this stuff in detail, by the way for reference and in order to be clear this is the file described in this post.

 

RSSComments

Flash Lite 1.1 capabilities

paco3 | 05/02/2008, 11:58

Hi, First of all I am a complete ignorant about FlashLite, but I am a FlashDesigner (more graphic than ActionScript programer) but very enthusiastic and with a lot of energy to learn.

I have this question: in order to get the bigest target market for mobiles, it is smart to design the FlasLite files for FlashLite 1.1?.. is this a smart way of thinking?,

What i want to do are forms, not games, photos or video, just nice, eyecatching forms, so in order to do this flashLite1.1 is enough? what can you suggest me?

thanks

Paco

You must login to post comments. Login
 

Rate This

 
 
Bookmark this page: DeliciousDiggFacebookGoogleYahooStumbleUponRedditDiigoTechnocratiTwitter  Share this page Share this page Print this Page Print this page Invite a friend Invite a friend
京ICP备05048969号    Email Newsletters Press Terms & Conditions Privacy Policy Sitemap Contact Us © 2009 Nokia 
RDF Facets: qdcZdescriptionQSxgioorgionatiliE20E7cE2002E20FebruaryE2cE202008E2017E3a56E20FlashE20E4citeE201E2e1E20collisionsAE20commonE20taskE20youE20mayE20needE20whenE20youE20startE20toE20developE20aE20FlashE20E4citeE201E2e1E20arcadeE20gameE20isE20toE20checkE20theE20collisionE20betweenE20theE20spritesE20onE20theE20screenE2eIfE20youE20surfE20theE20webE20youE20mayE20findE20tonsE20ofE20wayE20toE20detectE20theE20collisionE20inE20FlashE20butE20inE20FlashE20E4citeE201E2e1E20youE20haveE20referE20toE20theE20oldE20ActionScriptE201E2e0E20syntaE78E2eInE20thisE20postE20weE92llE20tryE20toE20eE78ploreE20theE20buildingE20blocksE20ofE20detectingE20collisionE20throughE20aE20sampleE20inE20whichE20aE20characterE20haveE20toE20getE20someE20giftE2eE2eE2eX qdcZidentifierQSxhttpE3aE2fE2fblogsE2eforumE2enokiaE2ecomE2fblogE2fgiorgioE2dnatilisE2dforumE2dnokiaE2dblogE2f2008E2f02E2f02E2fflashE2dliteE2d1E2e1E2dcollisionsX qdcZpublisherQUxhttpE3aE2fE2fswE2enokiaE2ecomE2fidE2fc764fd1cE2d8b06E2d499aE2d9a6aE2d17c3903d5a65E2fforumE5fnokiaE5fcrawlerE5fagentX qdcZtitleQSxGiorgioE20NatiliE27sE20ForumE20NokiaE20BlogE20E7cE20FlashE20E4citeE201E2e1E20collisionsX qdcZtypeQUqfnZE45E78cludedFromGeneralE4cistingsQ qdcZtypeQUqfntypeZBlogContentQ qdcZtypeQUqfntypeZBlogE45ntryQ qdcZtypeQUqfntypeZCommunityContentQ qdcZtypeQUqfntypeZE52esourceQ qdcZtypeQUqfntypeZWebpageQ qdcZtypeQUqmarsZManagedE52esourceQ qdcZtypeQUqwebZInformationE52esourceQ qdcZtypeQUqwebZPageQ qdcZtypeQUqwebZE52esourceQ qdcZtypeQUqrdfsZE52esourceQ qrssZdescriptionQSxgioorgionatiliE20E7cE2002E20FebruaryE2cE202008E2017E3a56E20FlashE20E4citeE201E2e1E20collisionsAE20commonE20taskE20youE20mayE20needE20whenE20youE20startE20toE20developE20aE20FlashE20E4citeE201E2e1E20arcadeE20gameE20isE20toE20checkE20theE20collisionE20betweenE20theE20spritesE20onE20theE20screenE2eIfE20youE20surfE20theE20webE20youE20mayE20findE20tonsE20ofE20wayE20toE20detectE20theE20collisionE20inE20FlashE20butE20inE20FlashE20E4citeE201E2e1E20youE20haveE20referE20toE20theE20oldE20ActionScriptE201E2e0E20syntaE78E2eInE20thisE20postE20weE92llE20tryE20toE20eE78ploreE20theE20buildingE20blocksE20ofE20detectingE20collisionE20throughE20aE20sampleE20inE20whichE20aE20characterE20haveE20toE20getE20someE20giftE2eE2eE2eX qfnZdistributionQUxhttpE3aE2fE2fblogsE2eforumE2enokiaE2ecomE2fX qfnZtopicQUqfnTopicZentertainmentQRqmarsZrelevanceQNx100X qfnZtopicQUqfnTopicZflashQRqdcZtypeQUqrdfsZE52esourceQRqmarsZrelevanceQNx100X qfnZtopicQUqfnTopicZgamesQRqdcZtypeQUqrdfsZE52esourceQRqmarsZrelevanceQNx100X qfnZtypeQUqfntypeZBlogContentQ qfnZtypeQUqfntypeZBlogE45ntryQ qfnZtypeQUqfntypeZCommunityContentQ qfnZtypeQUqfntypeZE52esourceQ qfnZtypeQUqfntypeZWebpageQ qfnZupdatedQDx2008E2d02E2d05X qfnZuserE5ftagQSxentertainmentX qfnZuserE5ftagQSxflashX qfnZuserE5ftagQSxgamesX qmarsZdescriptionQSxgioorgionatiliE20E7cE2002E20FebruaryE2cE202008E2017E3a56E20FlashE20E4citeE201E2e1E20collisionsAE20commonE20taskE20youE20mayE20needE20whenE20youE20startE20toE20developE20aE20FlashE20E4citeE201E2e1E20arcadeE20gameE20isE20toE20checkE20theE20collisionE20betweenE20theE20spritesE20onE20theE20screenE2eIfE20youE20surfE20theE20webE20youE20mayE20findE20tonsE20ofE20wayE20toE20detectE20theE20collisionE20inE20FlashE20butE20inE20FlashE20E4citeE201E2e1E20youE20haveE20referE20toE20theE20oldE20ActionScriptE201E2e0E20syntaE78E2eInE20thisE20postE20weE92llE20tryE20toE20eE78ploreE20theE20buildingE20blocksE20ofE20detectingE20collisionE20throughE20aE20sampleE20inE20whichE20aE20characterE20haveE20toE20getE20someE20giftE2eE2eE2eX qmarsZlanguageQUxhttpE3aE2fE2fswE2enokiaE2ecomE2flanguageE2d1E2fenX qrdfZtypeQUqfnZE45E78cludedFromGeneralE4cistingsQ qrdfZtypeQUqfntypeZBlogContentQ qrdfZtypeQUqfntypeZBlogE45ntryQ qrdfZtypeQUqfntypeZCommunityContentQ qrdfZtypeQUqfntypeZE52esourceQ qrdfZtypeQUqfntypeZWebpageQ qrdfZtypeQUqmarsZManagedE52esourceQ qrdfZtypeQUqwebZInformationE52esourceQ qrdfZtypeQUqwebZPageQ qrdfZtypeQUqwebZE52esourceQ qrdfZtypeQUqrdfsZE52esourceQ