I have a very basic code here:
[lua]-----------------------------------------------------------------------------------------
– main.lua
– Your code here
local physics = require(“physics”)
physics.start()
physics.setScale(60)
physics.setGravity(9.8, 0)
system.setAccelerometerInterval(100)
physics.setDrawMode(“normal”)
display.setStatusBar( display.HiddenStatusBar)
function onTilt( event )
physics.setGravity( (-9.8 * event.yGravity), (-9.8 * event.xGravity ))
myText.text = event.xGravity …"+" …event.yGravity
end
Runtime:addEventListener( “accelerometer”, onTilt)
borderBodyElement = { friction=0.5, bounce=0.3 }
local borderTop = display.newRect( 0, 0, 460, 20 )
borderTop:setFillColor( 100, 10, 10, 100) – make invisible
physics.addBody( borderTop, “static”, borderBodyElement )
local borderBottom = display.newRect( 20, 300, 460, 20 )
borderBottom:setFillColor( 100, 10,10, 100) – make invisible
physics.addBody( borderBottom, “static”, borderBodyElement )
local borderLeft = display.newRect( 0, 20, 20, 300 )
borderLeft:setFillColor( 100, 10, 10, 100) – make invisible
physics.addBody( borderLeft, “static”, borderBodyElement )
local borderRight = display.newRect( 460, 0, 20, 300 )
borderRight:setFillColor( 100, 10, 10, 100) – make invisible
physics.addBody( borderRight, “static”, borderBodyElement )
require “LevelHelperLoader”
–print(system.getInfo(“model”))
loader = LevelHelperLoader:initWithContentOfFile(“level1.plhs”)
loader:instantiateObjectsInGroup(physics)
–if(loader:hasPhysicBoundaries())then
– loader:createPhysicBoundaries(physics)
–end
local myText = display.newText("", 100,20, native.systemFont, 16)
myText:setTextColor(255,255,255)
myText.text = “System info”
local crate = display.newImage(“cardboard.png”)
crate.x = 150; crate.y = 250
physics.addBody( crate, { density=200, friction=50, bounce=0 } )[/lua]
The error is, box is responding normal when I move the phone BUT when I put it on the table for about 2-3 seconds and keep it still then the physics stop working, it looks like the box sticks to the wall and never moves an inch.
The funny thing is, it has the same principles as the shape tumbler sample in corona with less shapes (only 1 box) and it does not work.
any ideas ?
[import]uid: 73033 topic_id: 22267 reply_id: 322267[/import]