joelwe

Untitled

Mar 31st, 2013
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.05 KB | None | 0 0
  1. local collisionTable =
  2. {  
  3.     --paraGlideProp = bulletProp + firstParaPlatformProp + secondParaPlatformProp
  4.     paraGlideProp =
  5.     {
  6.         density = 1.0,
  7.         friction = 0.0,
  8.         shape=
  9.         {  
  10.             -20, 81.5  ,  -70, -28.5  ,  55, -29.5  
  11.         },
  12.         bounce = 0.0,
  13.         filter =
  14.         {
  15.             categoryBits = 1,
  16.             maskBits = 52
  17.         }
  18.     },
  19.     --secondParaPlatformProp = paraGlideProp + bombProp + fragProp
  20.     secondParaPlatformProp =
  21.     {
  22.         density = 100000.0,
  23.         friction = 1000.0,
  24.         bounce = 0.0,
  25.         filter =
  26.         {
  27.             categoryBits = 32,
  28.             maskBits = 641
  29.        }
  30.     },
  31.     --bombProp = secondParaPlatformProp + bulletProp
  32.     bombProp =
  33.     {
  34.         density = 1.0,
  35.         friction = 0.3,
  36.         bounce = 0.2,
  37.         filter =
  38.         {
  39.             categoryBits = 128,
  40.             maskBits = 36
  41.        }
  42.     },
  43.     --fragProp = secondParaPlatformProp
  44.     fragProp =
  45.     {
  46.         shape = {   -3.5, 21  ,  -4.5, 24  ,  -7.5, 23  ,  -7.5, 20  ,  -5.5, 17  },
  47.         filter =
  48.         {
  49.             categoryBits = 512,
  50.             maskBits = 32
  51.        }
  52.     }  
  53. }
  54.  
  55. local frag = getSprite( spriteData.fragData )
  56. frag.name = "frag"
  57. frag.x = 200
  58. frag.y = 10
  59. frag.collision = onCatchPlatformCollision2
  60. frag:addEventListener("collision", frag)
  61. physics.addBody( frag, "dynamic", collisionTable.fragProp)
  62. frag:play()
  63.  
  64. function setUpCatchPlatform2()
  65.  
  66.     local platform2 = display.newRect( 0, 0, display.contentWidth * 4, 0)
  67.     platform2.myName = "platform2"
  68.     platform2.x =  (display.contentWidth / 2)
  69.     platform2.y = (display.contentHeight / 2) + 135
  70.     physics.addBody(platform2, "static", collisionTable.secondParaPlatformProp)
  71.  
  72.     platform2.collision = onCatchPlatformCollision2
  73.     platform2:addEventListener( "collision", platform2 )
  74.  
  75. end
  76.  
  77. function onCatchPlatformCollision2(self, event)
  78.     if event.phase == "began" and event.other.name == "frag" then
  79.         print("frag")
  80.     end
  81. end
Advertisement
Add Comment
Please, Sign In to add comment