Reputation: 11532
How to prevent sprite from rotation inside Corona ? When I set
-- 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
it is ignored but when I inside touch function do like
function touch(event)
event.target.isFixedRotation = true
end
after touch it works. Does anyone know what is a problem ?
Upvotes: 1
Views: 120
Reputation: 7390
Add physics
to the body first, then assign isFixedRotation
to it. Like:
--Add a body to the rectangle
physics.addBody( spriteInstance, "dynamic" )
-- Assign your property
myRect.isFixedRotation = true
Here you are assigning isFixedRotation = true
during the touch
event. So, remove that code within your touch function and add it just after creating the physics body as:
spriteInstance.isFixedRotation = true
Keep Coding............. :)
Upvotes: 2