Lua 如何防止精灵在电晕内旋转?

Lua 如何防止精灵在电晕内旋转?,lua,coronasdk,Lua,Coronasdk,如何防止精灵在电晕内旋转? 当我设定 -- Create a new sprite and add it to the group local spriteInstance = display.newSprite( imagesheet, spriteSequences.cat ) spriteInstance.x = 100 spriteInstance.y = 100 spriteInstance.isFixedRotation = true 它被忽略了,但当我在触摸功能做喜欢 func

如何防止精灵在电晕内旋转? 当我设定

-- Create a new sprite and add it to the group
local spriteInstance = display.newSprite( imagesheet, spriteSequences.cat )
spriteInstance.x = 100
spriteInstance.y = 100
spriteInstance.isFixedRotation  = true
它被忽略了,但当我在触摸功能做喜欢

function touch(event)

    event.target.isFixedRotation = true
end

触摸后,它工作。有人知道什么是问题吗

首先向主体添加
物理
,然后将
isFixedRotation
分配给主体。比如:

--Add a body to the rectangle
physics.addBody( spriteInstance, "dynamic" )

-- Assign your property
myRect.isFixedRotation = true
touch
事件期间,您正在分配
isFixedRotation=true
。因此,删除触摸功能中的代码,并在创建物理实体后添加该代码,如下所示:

spriteInstance.isFixedRotation = true
继续编码…………:)

澄清“它被忽略”和“它起作用”:是什么让你说它被忽略了,是什么让你说它起作用