Advertisement
Guest User

Untitled

a guest
Jan 22nd, 2020
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. function TABLE.createJump(posX)
  2.  
  3. function jumpCollision(event)
  4. audio.play(jump_fx)
  5. event.other:applyForce(0, -15, event.other.x, event.other.x)
  6. event.target:play()
  7. timer.performWithDelay(30, function() event.other.onAir = true end, 10)
  8. end
  9.  
  10. local data = require("assets.sprites.jump")
  11. local map = graphics.newImageSheet("assets/sprites/jump.png", data:getSheet() )
  12. local animations = {
  13. {name="normal", start=1, count=3, time=500, loopCount = 1, loopDirection = "bounce"},
  14. }
  15. local jump= display.newSprite( map, animations )
  16. _G.elements_group:insert(jump)
  17. jump.x = posX; jump.y = 370
  18. jump.type = "ground"
  19. jump:setSequence("normal")
  20. local shape = { halfWidth=10, halfHeight=32, x=0, y=-0, }
  21. physics.addBody(jump, "dynamic", {friction= 1, density= 200, box=shape})
  22. jump:addEventListener("collision", jumpCollision)
  23. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement