physics - create a floating leaf?

Should be something closer to this:

local bigLeaf = newImage() --follow the documentation for the parameters  
physics.addBody( bigLeaf, ... ) --again, see physics documentation for "addBody" parameters  
  
local randomXforce = math.random( 0.5, 1 )  
local randomYforce = math.random( 0.5, 1 )  
  
bigLeaf:applyLinearImpulse( randomXforce, randomYforce, bigLeaf.x, bigLeaf.y )  

Does that help? [import]uid: 9747 topic_id: 30037 reply_id: 120381[/import]

Thanks for the post. I havent tried it yet but i would like to just make sure I understand correctly…

local randomXforce = math.random( 0.5, 1 )

In the above, “randomXforce” is the name of my variable, right? >_>
Thanks, Brent! :slight_smile: [import]uid: 157993 topic_id: 30037 reply_id: 120496[/import]

Yes, exactly. Any time you see something like “local ... = ”, with the “...” being some name, that’s a custom local variable declared by the user, not a Lua or Corona reserved name. It might be possible to actually declare variables named the same as a reserved function, but it would be really awful coding practice so I’ve never even considered it. :stuck_out_tongue:

Of course, if you see something like “... = ” (same as above but without the “local” prefix), this could mean two things: 1) either this a global variable being declared right at that time (not recommended; global variables are largely frowned up in Lua)… OR 2) it means that the variable was already declared somewhere above, in which case the statement now references that variable (in other words, it’s not creating a new “copy” of it).

--NEW variable declaration:  
local myVariable = 0  
  
--REFERENCE notation:  
local myVariable = 0 --declare it!  
myVariable = 10 --now change its value!  

Brent
[import]uid: 9747 topic_id: 30037 reply_id: 120497[/import]