类型 数字 对象 DisplayObject(显示对象) 库 display.* 修订版本 版本 2024.3703 关键词 rotation, object, rotate(旋转,对象,旋转) 另请参阅 object:rotate()
以度为单位设置对象的旋转角度;此旋转基于顺时针方向,其中 `0` 表示正上方。旋转围绕对象的锚点进行。
也可以使用 object:rotate() 函数设置旋转。
在碰撞事件期间,不能对物理 body(物体) 使用此属性。但是,您的碰撞处理程序可以设置一个标志或通过 timer.performWithDelay() 包含一个时间延迟,以便该操作可以在下一个应用程序周期或之后发生。有关哪些 API 和方法受此规则约束的完整列表,请参阅碰撞检测指南。
local rect = display.newRect( 100, 100, 50, 50 ) rect:setFillColor( 1, 1, 1 ) rect.rotation = 45 print( rect.rotation ) -- Prints 45 in the terminal
local rect = display.newRect( 50, 50, 100, 150 )
rect:setFillColor( 1, 0, 0 )
rect.rotation = -45
local reverse = 1
local function rockRect()
if ( reverse == 0 ) then
reverse = 1
transition.to( rect, { rotation=-45, time=500, transition=easing.inOutCubic } )
else
reverse = 0
transition.to( rect, { rotation=45, time=500, transition=easing.inOutCubic } )
end
end
timer.performWithDelay( 600, rockRect, 0 ) -- Repeat forever