How to make a permanently rotating object?

This does not work

ob = display.newRect(0,0,100,100)
physics.addBody( ob, “static”, { density=1.0, shape = ob.shape } )
ob.angularVelocity = 10
ob:applyTorque( 100 )

and this neither:

function getObject()

local p = display.newRect(0,0,100,100)

local function loop()
p.rotation = p.rotation + 10
end

Runtime:addEventListener( “enterFrame”, loop )
return p
end

local ob = getObject()
I get no errors in both cases but the object does not rotate in any case.
[import]uid: 21280 topic_id: 5580 reply_id: 305580[/import]

Hi, modifying your existing code…

this works :

local p = display.newRect(0,0,100,100)  
  
local function loop()  
p.rotation = p.rotation + 10  
end  
  
Runtime:addEventListener( "enterFrame", loop )  

Hope that helps [import]uid: 6981 topic_id: 5580 reply_id: 19034[/import]

Yep I know this would work but I was thinking of having the rotating functionality encapsulated in the getObject() “object”.

getObject() is a function in separate module, whose purpose is to return as many rotating objects as I need, and they would all rotate on their own without the need to any intervention from the code outside the object itself.

I hope I made it more clear this time what I’m trying to achieve. [import]uid: 21280 topic_id: 5580 reply_id: 19035[/import]