Updating gravity

Posted by mightE, Posted on September 19, 2011

0 votes

:D I found a way, I don't think it has been posted (if it is I look stupid :L )

This code will update the gravity on every enterFrame (should probably change that to a timer every second) to the variable grav.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
grav = 1
function gravi()
print(grav)
grav = 10
print(grav)
end
timer.performWithDelay(5000,gravi)      
 
--]]
physics = require( "physics" )
physics.start()
 
function checkgrav()
gx, gy = physics.getGravity()
print(gx, gy)
physics.setGravity( 0, grav)
end
Runtime:addEventListener( "enterFrame", checkgrav )


Replies

horacebury's picture
horacebury
User offline. Last seen 1 hour 56 min ago. Offline
Joined: 17 Aug 2010

Did you get a look at this sample?

http://developer.anscamobile.com/content/shape-tumbler