Advertisement
Guest User

physics test

a guest
Aug 7th, 2019
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.44 KB | None | 0 0
  1. local composer = require( 'composer' )
  2. local physics = require( 'physics' )
  3. berry = require( 'pl.ldurniat.berry' )
  4. local tiled = require( "com.ponywolf.ponytiled" )
  5. local json = require( "json" )
  6.  
  7. local scene = composer.newScene()
  8.  
  9.  
  10. function scene:create( event )
  11.  
  12. local sceneGroup = self.view
  13.  
  14. ---[[
  15. local physics = require( 'physics' )
  16. berry = require( 'pl.ldurniat.berry' )
  17.  
  18. physics.start()
  19.  
  20.  
  21. local map = berry.loadMap( 'Map.json' )
  22. local visual = berry.createVisual( map )
  23. berry.buildPhysical( map )
  24.  
  25. Ball = display.newCircle( display.contentCenterX, display.contentCenterY, 10)
  26. Ball.angularDamping = 1
  27. Ball.strokeWidth = 1
  28. Ball:setFillColor( 0.25, 0.5, 0.25 )
  29. Ball:setStrokeColor( 0, 3, 0 )
  30.  
  31. physics.addBody(Ball, 'dynamic', { friction = 0.5, bounce = 0.2, radius = 10 } )
  32.  
  33. visual:insert( Ball )
  34. sceneGroup:insert( visual )
  35.  
  36. end
  37.  
  38. function scene:show( event )
  39. local sceneGroup = self.view
  40. local phase = event.phase
  41. if phase == 'will' then
  42.  
  43. elseif phase == 'did' then
  44.  
  45. end
  46. end
  47.  
  48. function scene:hide( event )
  49. local sceneGroup = self.view
  50. local phase = event.phase
  51. if event.phase == 'will' then
  52.  
  53. elseif phase == 'did' then
  54.  
  55. end
  56. end
  57.  
  58. function scene:destroy( event )
  59. local sceneGroup = self.view
  60.  
  61.  
  62. end
  63.  
  64. scene:addEventListener( 'create', scene )
  65. scene:addEventListener( 'show', scene )
  66. scene:addEventListener( 'hide', scene )
  67. scene:addEventListener( 'destroy', scene )
  68.  
  69. return scene
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement