Galedajs Posted October 5, 2011 Report Share Posted October 5, 2011 Sveiki, šeit ir mans kods: package { import flash.display.MovieClip; import flash.display.DisplayObject; public class Package extends MovieClip { var Height:int; var Water:water; var Dirt:dirt; public function Package() { Water = new water(); Dirt = new dirt(); var level:Array = [[Water,Water,Dirt,Water,Water], [Water,Dirt,Dirt,Water,Water], [Dirt,Dirt,Water,Water,Water], [Water,Water,Water,Water,Water]]; for (var row:int = 0; row <= 3; row++) { for (var column:int = 0; column <= 4; column++) { trace( row, column, level[row][column] ); switch (level[row][column].toString()){ case "[object water]": Water = new water(); addChild(Water); Water.x = column * level[row][column].width; Water.y = row * level[row][column].width; case "[object dirt]": Dirt = new dirt(); addChild(Dirt); Dirt.x = column * level[row][column].width; Dirt.y = row * level[row][column].height; } } } } } } Es gribētu saprast to, kā var addChild iedarbināt tur neizmantojot switch(). Jo ko es darītu tad, ja man būtu kādi 500 objekti, tad vajadzētu taisīt 500 switch casus, kas visticamāk reāli nobremzētu. Noteikti ir kāda labāka metode tam visam, tādēļ gaidu kādu ieteikumu, palīdzību. Quote Link to comment Share on other sites More sharing options...
Kemito Posted October 5, 2011 Report Share Posted October 5, 2011 (edited) Ieliec lūdzu code tagos šo, lai var vieglāk saprast, jeb http://paste.php.lv šeit. Nu ja ir vairāk, tad darbini ciklā. Edited October 5, 2011 by Kemito Quote Link to comment Share on other sites More sharing options...
e-remit Posted October 5, 2011 Report Share Posted October 5, 2011 Paprovē šādi: http://paste.php.lv/bd9b227e6f696b8b31f8b7f7d51cfdf6?lang=actionscript Quote Link to comment Share on other sites More sharing options...
Galedajs Posted October 5, 2011 Author Report Share Posted October 5, 2011 Paprovē šādi: http://paste.php.lv/...ng=actionscript Tikmēr, kamēr es neizņemu šīs rindas: tile.row = row; tile.column = column; tikmēr parādās šāds error: ReferenceError: Error #1056: Cannot create property row on water. at Package() bet kad tās izņemu, tad darbojas. Priekš kā īsti tās divas rindas ir paredzētas? Quote Link to comment Share on other sites More sharing options...
e-remit Posted October 5, 2011 Report Share Posted October 5, 2011 nu, ja tev nevajag, vari iztikt. es vnk. nezināju, ka tiem MovieClip'iem arī linkage klases piesaistītas. es vispār savādāk tur visu ko definētu, tāpēc arī, paraduma pēc, piemetu to klāt. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.