2014-09-28 49 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 

保持编码............. :)