Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local physics = require("physics")
- physics.setDrawMode("hybrid")
- physics.start(true)
- physics.setGravity(0,9.8)
- display.setStatusBar( display.HiddenStatusBar )
- local bkg = display.newImage( "bkg_cor.png" )
- local grass = display.newImage("grass.png")
- grass.x = 160; grass.y = 430
- local grass2 = display.newImage("grass2.png") -- non-physical decorative overlay
- grass2.x = 160; grass2.y = 440
- physics.addBody( grass, "static", { friction=0.5, bounce=0.3 } )
- local crates = {}
- local stopit = false --make it true to stop instead of pause, you wont see problem
- local displace = 0
- --local dropCrates = timer.performWithDelay( 500, newCrate, 100 )
- function startagain()
- physics.start(true)
- if stopit then
- local grass = display.newImage("grass.png")
- grass.x = 160; grass.y = 430
- physics.addBody( grass, "static", { friction=0.5, bounce=0.3 } )
- end
- if displace == 0 then
- displace = 10 --change this to > 30(since crate dimension is 30), won;t see the problem
- else
- displace = 0
- end
- SetCretes()
- end
- function CreatePhysicsProblem()
- for i=1,#crates do
- crates[i]:removeSelf()
- crates[i] = nil
- end
- crates = nil
- crates= {}
- if stopit then
- physics.stop()
- else
- physics.pause()
- end
- timer.performWithDelay( 1000, startagain )
- end
- function SetCretes()
- local j = display.newImageRect("crate.png",30,30);
- crates[#crates+1] = j
- j.x = 60+displace
- j.y = 405--335
- physics.addBody( j, { density=3, friction=.500, bounce=0} )
- local j = display.newImageRect("crate.png",30,30);
- crates[#crates+1] = j
- j.x = 60+displace
- j.y = 368
- physics.addBody( j, { density=3, friction=.500, bounce=0} )
- local j = display.newImageRect("crate.png",30,30);
- crates[#crates+1] = j
- j.x = 60+displace
- j.y = 330--402
- physics.addBody( j, { density=3, friction=.500, bounce=0} )
- timer.performWithDelay( 2000, CreatePhysicsProblem)
- end
- SetCretes()
Advertisement
Add Comment
Please, Sign In to add comment