1 Reply Latest reply on Oct 5, 2009 11:19 AM by shintashi

    collision detection for attached tiles?

    shintashi Level 1

      I'm having trouble getting a collision detection to work for attached movieclip tiles (from library). The mc (pallete) they attach to detects collision, but the tiles themselves (pallete.k1 - pallete.k32) detect nothing. What's going on?

       

      //my script

      //----------------

      function map(clip, kval, num, coordinatex, coordinatey){var kval:MovieClip = pallete.attachMovie(clip,clip+num , pallete.getNextHighestDepth());
      kval._x = coordinatex; kval._y = coordinatey;}

       

      function $map1(tl1, tl2, tl3, tl4, tl5, tl6, tl7, tl8){ 
      map(tl1, k1, 1, 0, 0);
      map(tl2, k2, 2, 50, 0);
      map(tl3, k3, 3, 100, 0);
      map(tl4, k4, 4, 150, 0);
      map(tl5, k5, 5, 200, 0);
      map(tl6, k6, 6, 250, 0);
      map(tl7, k7, 7, 300, 0);
      map(tl8, k8, 8, 350, 0);
      }

       

      function $map2(tl1, tl2, tl3, tl4, tl5, tl6, tl7, tl8){ 
      map(tl1, k9, 9, 0, 50);
      map(tl2, k10, 10, 50, 50);
      map(tl3, k11, 11, 100, 50);
      map(tl4, k12, 12, 150, 50);
      map(tl5, k13, 13, 200, 50);
      map(tl6, k14, 14, 250, 50);
      map(tl7, k15, 15, 300, 50);
      map(tl8, k16, 16, 350, 50);
      }

       

      function $map3(tl1, tl2, tl3, tl4, tl5, tl6, tl7, tl8){ 
      map(tl1, k17, 17, 0, 100);
      map(tl2, k18, 18, 50, 100);
      map(tl3, k19, 19, 100, 100);
      map(tl4, k20, 20, 150, 100);
      map(tl5, k21, 21, 200, 100);
      map(tl6, k22, 22, 250, 100);
      map(tl7, k23, 23, 300, 100);
      map(tl8, k24, 24, 350, 100);
      }

       

      function $map4(tl1, tl2, tl3, tl4, tl5, tl6, tl7, tl8){ 
      map(tl1, k25, 25, 0, 150);
      map(tl2, k26, 26, 50, 150);
      map(tl3, k27, 27, 100, 150);
      map(tl4, k28, 28, 150, 150);
      map(tl5, k29, 29, 200, 150);
      map(tl6, k30, 30, 250, 150);
      map(tl7, k31, 31, 300, 150);
      map(tl8, k32, 32, 350, 150);
      }

       

      $map1("tile", "tile1", "tile", "tile1", "tile", "tile1", "tile", "tile1");
      $map2("tile1", "tile", "tile1", "tile", "tile1", "tile", "tile1", "tile");
      $map3("tile", "tile1", "tile", "tile1", "tile", "tile1", "tile", "tile1");
      $map4("tile1", "tile", "tile1", "tile", "tile1", "tile", "tile1", "tile");

       

      onEnterFrame = function(){
      if(Key.isDown(Key.LEFT)){man._x -= 8;}
      if(Key.isDown(Key.RIGHT)){man._x += 8;}
      if(Key.isDown(Key.UP)){man._y -= 8;}
      if(Key.isDown(Key.DOWN)){man._y += 8;}
      if(man.hitTest(pallete.k1)){pallete.k1._rotation = 45;}   
         
          }

        • 1. Re: collision detection for attached tiles?
          shintashi Level 1

          The "k" in k1,k2,k3...k32 disappears.

           

          I checked the object list in debug,

          problem solved:

           

          tile.k1 is actually read as tile 1, while tile1.k2 is read as tile12. I should probably change the name of the tiles to not end in numbers, otherwise tile-12 and tile1-2 will both read as tile12

           

          Level #0: Frame=1
            Movie Clip: Frame=1 Target="_level0.pallete"
              Shape:
              Movie Clip: Frame=1 Target="_level0.pallete.tile1"
                Shape:
              Movie Clip: Frame=1 Target="_level0.pallete.tile12"
                Shape:
              Movie Clip: Frame=1 Target="_level0.pallete.tile3"
                Shape:
              Movie Clip: Frame=1 Target="_level0.pallete.tile14"
                Shape:
              Movie Clip: Frame=1 Target="_level0.pallete.tile5"
                Shape:
              Movie Clip: Frame=1 Target="_level0.pallete.tile16"
                Shape:
              Movie Clip: Frame=1 Target="_level0.pallete.tile7"
                Shape:
              Movie Clip: Frame=1 Target="_level0.pallete.tile18"
                Shape:
              Movie Clip: Frame=1 Target="_level0.pallete.tile19"
                Shape:
              Movie Clip: Frame=1 Target="_level0.pallete.tile10"
                Shape:
              Movie Clip: Frame=1 Target="_level0.pallete.tile111"
                Shape:
              Movie Clip: Frame=1 Target="_level0.pallete.tile12"
                Shape:
              Movie Clip: Frame=1 Target="_level0.pallete.tile113"
                Shape:
              Movie Clip: Frame=1 Target="_level0.pallete.tile14"
                Shape:
              Movie Clip: Frame=1 Target="_level0.pallete.tile115"
                Shape:
              Movie Clip: Frame=1 Target="_level0.pallete.tile16"
                Shape:
              Movie Clip: Frame=1 Target="_level0.pallete.tile17"
                Shape:
              Movie Clip: Frame=1 Target="_level0.pallete.tile118"
                Shape:
              Movie Clip: Frame=1 Target="_level0.pallete.tile19"
                Shape:
              Movie Clip: Frame=1 Target="_level0.pallete.tile120"
                Shape:
              Movie Clip: Frame=1 Target="_level0.pallete.tile21"
                Shape:
              Movie Clip: Frame=1 Target="_level0.pallete.tile122"
                Shape:
              Movie Clip: Frame=1 Target="_level0.pallete.tile23"
                Shape:
              Movie Clip: Frame=1 Target="_level0.pallete.tile124"
                Shape:
              Movie Clip: Frame=1 Target="_level0.pallete.tile125"
                Shape:
              Movie Clip: Frame=1 Target="_level0.pallete.tile26"
                Shape:
              Movie Clip: Frame=1 Target="_level0.pallete.tile127"
                Shape:
              Movie Clip: Frame=1 Target="_level0.pallete.tile28"
                Shape:
              Movie Clip: Frame=1 Target="_level0.pallete.tile129"
                Shape:
              Movie Clip: Frame=1 Target="_level0.pallete.tile30"
                Shape:
              Movie Clip: Frame=1 Target="_level0.pallete.tile131"
                Shape:
              Movie Clip: Frame=1 Target="_level0.pallete.tile32"
                Shape:
            Movie Clip: Frame=1 Target="_level0.man"
              Shape: