2014-09-28 53 views
1

如何防止精靈在電暈內旋轉? 當我設置如何防止精靈在電暈內旋轉?

-- 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 

觸摸後它的工作原理。有誰知道什麼是問題?

+0

澄清「它被忽略「和」它的作用「:是什麼讓你說它被忽略,是什麼讓你說它的作品 – Schollii 2014-09-28 04:09:08

回答

2

physics加到身上,然後分配給isFixedRotation。像:

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

-- Assign your property 
myRect.isFixedRotation = true 

這裏您在touch活動期間分配isFixedRotation = true。所以,免除您的觸摸功能內的代碼,並添加它只是創造了物理身體後:

spriteInstance.isFixedRotation = true 

保持編碼............. :)