Advertisement
Guest User

Untitled

a guest
Jul 18th, 2014
226
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.12 KB | None | 0 0
  1. local mydata = require("mydata")
  2. local humanoid
  3.  
  4. mydata.humanoids = {}
  5. local scrollSpeedX = 0
  6.  
  7.  
  8. function createHumanoid(layer)
  9.  
  10. local layer = layer or display.currentStage
  11.  
  12. for i = 1, 10 do
  13.  
  14. humanoid = display.newRect(0, 0, 10, 10)
  15. humanoid.x = math.random(-1000, 1000)
  16. humanoid.y = 260
  17. physics.addBody(humanoid, { isSensor = true })
  18. mydata.humanoids[#mydata.humanoids + 1] = humanoid
  19. end
  20.  
  21. function updateHumanoid()
  22.  
  23. if switchTerrain == 0 then
  24.  
  25. if player.x <= 100 then scrollSpeedX = 0
  26.  
  27. else scrollSpeedX = -player.x / 70
  28. end
  29.  
  30. if humanoid.x
  31.  
  32. then
  33. humanoid.x = humanoid.x + scrollSpeedX
  34. end
  35.  
  36. elseif switchTerrain == 1 then
  37.  
  38. if player.x <= 100 then scrollSpeedX = 0
  39.  
  40. else scrollSpeedX = player.x / 70
  41. end
  42.  
  43. if humanoid.x
  44.  
  45. then
  46. humanoid.x = humanoid.x + scrollSpeedX
  47. end
  48. end
  49. end
  50.  
  51. Runtime:addEventListener("enterFrame", updateHumanoid)
  52. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement