I’m having trouble with Lua. Below is my code:
function newBean()
newBean = display.newImage( "image.png" );
newBean.x = display.contentWidth\*0.5
newBean.y = -100
newBean.myName = "bean1"
physics.addBody( newBean, { density=0.9, friction=0.3, bounce=0} )
end
function moveTest(event)
local vx,vy = bean1:getLinearVelocity()
print (vx,vy)
end
Runtime:addEventListener( "enterFrame", moveTest )
When I try to refer back to “bean1” in the second function I get a runtime error that this is a nil value. How can I refer back to objects created in other functions in order to report on their status later on? [import]uid: 31694 topic_id: 6484 reply_id: 306484[/import]