I am using this code to spawn a object but the object is not falling (transition) smooth in the game.
yForBack = 6000 yForB1A = 2000 yForB1B = 3000 yForB2A = 2000 yForB2B = 3000 yForB3A = 2000 yForB3B = 3000 yForGCa = 2000 yForGCb = 3000 local screenGroup = self.view local randomBackC = function() local backC = display.newImage("Cloud"..tostring(math.random(1, 4))..".png") backC.x = math.random (0, 450); backC.y = -50 physics.addBody( backC, { density=.1, bounce=0.1, friction=.2, radius=45, filter=nonfilter } ) backC.name = "badclouts" physics.addBody(backC, {bounce=0, filter=b}) backC.isSensor = true backC.rotation = math.random(-20,20) -- Rotate the object backC:applyForce( 0, yForBack, backC.x, backC.y ) -- apply the force to your cloud transition.to( backC, { time=yForBack, y=600, } ) backC.gravityScale = 0.0 print("yForBack " .. yForBack) local cleanup cleanup = function() if backC then if backC.y \>600 then backC:removeSelf() backC = nil end end end Runtime:addEventListener("enterFrame", cleanup) end randomBackC1 = timer.performWithDelay( 500, randomBackC, 0 ) local function speatTimer() yForBack = yForBack - 1 yForB1A = yForB1A - 1 yForB1B = yForB1B - 1 yForB2A = yForB2A - 1 yForB2B = yForB2B - 1 yForB3A = yForB3A - 1 yForB3B = yForB3B - 1 yForGCa = yForGCa - 1 yForGCb = yForGCb - 1 end local SpeedTimerall = timer.performWithDelay( 100, speatTimer, 500 )
Is there anything i can do to make it smoother ?
Kevin-