Advertisement
Guest User

Untitled

a guest
Jul 28th, 2013
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.40 KB | None | 0 0
  1. gamescene = gideros.class(Sprite)
  2.  
  3. function gamescene:init()
  4. Level = TiledAsWorldEditor.new("level.lua")
  5.  
  6. self:addChild(Level)
  7.  
  8. TiledAsWorldEditor:EnableDebugDrawing(world)
  9.  
  10. self.lander = self:lander(400, 100)
  11.  
  12. end
  13.  
  14.  
  15. function gamescene:lander(x, y)
  16.  
  17.  
  18. local lander1 = Bitmap.new(Texture.new("images/lander.png"))
  19. local lander2 = Bitmap.new(Texture.new("images/lander2.png"))
  20. local lander3 = Bitmap.new(Texture.new("images/lander3.png"))
  21.  
  22. lander1:setAnchorPoint(0.5, 0.5)
  23. lander2:setAnchorPoint(0.5, 0.5)
  24. lander3:setAnchorPoint(0.5, 0.5)
  25.  
  26. local lander = MovieClip.new{
  27. {1, 1, lander1},
  28. {2, 4, lander2},
  29. {5, 7, lander3},
  30. }
  31.  
  32. lander:setGotoAction(7, 2)
  33.  
  34. function lander:switchAnimation()
  35.  
  36. if stopped == true then
  37. self:gotoAndPlay(2)
  38.  
  39. stopped = false
  40.  
  41. end
  42.  
  43. end
  44.  
  45. function lander:switchAnimation2()
  46. self:gotoAndStop(1)
  47.  
  48. stopped = true
  49. end
  50.  
  51. lander:setPosition(x,y)
  52.  
  53. local body = self.world:createBody{type = b2.DYNAMIC_BODY}
  54. body:setPosition(lander:getX(), lander:getY())
  55. body:setAngle(lander:getRotation() * math.pi/180)
  56. body:setLinearVelocity(0, 0)
  57.  
  58.  
  59.  
  60. local polygon = b2.PolygonShape.new()
  61. polygon:set(0, -22, 16, 10, -16, 10)
  62. local fixture = body:createFixture{shape = polygon, density = 1.0,
  63. friction = 0.6, restitution = 0.01}
  64. lander.body = body
  65. lander.body.type = "lander"
  66.  
  67. self:addChild(lander)
  68.  
  69. return lander
  70. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement