Если я правильно понимаю
- вы пытаетесь заставить шар вращаться бесконечно в направлении туда-сюда
- заставить мяч отскочить
Код ниже будет работать для этого:
local physics=require("physics")
physics.start()
--make a box
local box1 = display.newRect( 50, 420, 150, 150 )
box1:setFillColor(255,255,255)
physics.addBody( box1, "static", { friction=0, bounce=0.0 } )
-- make a ball (off-screen) and position it
local ball = display.newImage( "scnGame_bird.png", 20, 20 )
ball.x, ball.y = 100, 200
-- add physics to the ball
physics.addBody( ball, { density = 1.0, friction = 0, bounce = 0.8, radius = 19 } )
--rotate the ball
--ball.rotation = -365
local rotateBallReverse
local function rotateBall()
transition.to( ball, { time=1000, rotation=365, onComplete=rotateBallReverse} )
end
rotateBallReverse = function()
transition.to( ball, { time=1000, rotation=-365, onComplete=rotateBall} )
end
rotateBall()
В остальном, что вы имеете в виду под «предотвратить движение x»?