Guest User

Untitled

a guest
Jun 30th, 2013
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.23 KB | None | 0 0
  1. BUDSPRITES.LUA
  2.  
  3. local sheets = {}
  4. local sequences = {}
  5.  
  6. -- Attach them to our module
  7. --
  8. public.sheets = sheets
  9. public.sequences = sequences
  10.  
  11. sheets.invaders = {}
  12. public.createSpriteStuff = function()
  13. local sheetData = {
  14. width = 53, --the width of each frame
  15. height = 38, --the height of each frame
  16. numFrames = 2, --the total number of frames on the sheet
  17. }
  18.  
  19. _G.myvalue = myvalue
  20. local i
  21. for i=1,5 do
  22. sheets.invaders[i] = graphics.newImageSheet("images/sprite"..i..".png", sheetData )
  23.  
  24. if
  25.  
  26. i == 1 then
  27. myvalue =100
  28.  
  29. elseif
  30. i == 2 then
  31. myvalue = 200
  32.  
  33. elseif
  34. i == 3 then
  35. myvalue = 300
  36.  
  37. elseif
  38. i == 4 then
  39. myvalue = 400
  40.  
  41. elseif
  42. i == 5 then
  43. myvalue = 500
  44.  
  45. end
  46.  
  47. end
  48.  
  49. sequences.normRun =
  50. {
  51. name = "normalRun",
  52. start = 1,
  53. count = 2,
  54. time = 1710,
  55. loopCount = 0,
  56. loopDirection = "forward"
  57. }
  58.  
  59. MAIN.LUA
  60.  
  61. function createInvader(xloc, yloc, row, myvalue)
  62. scene = display.newGroup()
  63. if levelDrop > 350 then
  64. levelDrop = 350
  65. end
  66.  
  67. for j = 1, 5 do
  68. for i = 1, 11 do
  69. allEnemys[#allEnemys + 1] = enemys:new()
  70. allEnemys[#allEnemys]:init(i * 60, j * 70 + levelDrop, j) --spacing horizontal--spacing vertical -- top screen spacing
  71. allEnemys[#allEnemys]:start()
  72.  
  73. end
  74. end
  75. end
  76.  
  77. ENEMY.LUA
  78. function enemys:init(xloc, yloc, row, myvalue )
  79.  
  80. self.image = display.newSprite(budSprites.sheets.invaders[row], budSprites.sequences.normRun)
  81. self.image:setReferencePoint( CenterReferencePoint )
  82. self.image.x = xloc
  83. self.image.y = yloc
  84. self.myvalue = myvalue
  85. self.image.name = "enemy"
  86. self.movement = 0.5
  87. self.leftHit = 0
  88. self.rightHit = 0
  89. self.numberOfWallHits = 0
  90. self.floorHits = 0
  91. self.image:play()
  92. local enemyCollisionFilter = { categoryBits = 64, maskBits = 111}
  93. physics.addBody( self.image, {isSensor = true, filter = enemyCollisionFilter})
  94. bgmChan1 = audio.play(bgm1,{channel=9, loops = -1})
  95. end
  96.  
  97. --SCORING IN ENEMY.LUA
  98. local currentScore = getScores( )
  99. currentScore = currentScore + myvalue
  100. setScores( currentScore )
Advertisement
Add Comment
Please, Sign In to add comment