This code creates my keys
function scoreUp() -- body score = score + 100 user.score2 = score scoreText.text = "Score:"..score scoreText.anchorX = 1 scoreText.x = screenRight - scoreText.width \* 0.2 loadsave.saveTable(user,"user.json") if user.score2 \>= 20000 then local keyRand = math.random(1,200) if keyRand \> 198 then print("key rand is ';".. keyRand) keyCounter = keyCounter + 1 keys[keyCounter] = display.newImageRect( sceneGroup, "menuImages/ruby.png",40,60) keys[keyCounter].x = math.random(screenLeft + 80 , screenRight - 80) keys[keyCounter].y = screenTop - keys[keyCounter].height keys[keyCounter].name = "key" physics.addBody(keys[keyCounter],"dynamic") keys[keyCounter].isFixedRotation = true trans\_key = transition.to (keys[keyCounter],{y = screenBottom + keys[keyCounter].height , time = math.random(1200,1500)}) end end end
this code is of ball
-- check which ball to display if user.isRedEnabled == true then ball = display.newImageRect(sceneGroup,"upImages/ball/red-white-ball.png",75,75) elseif user.isYellowEnabled == true then ball = display.newImageRect(sceneGroup,"upImages/ball/yellow-white-ball.png",75,75) elseif user.isPurpleEnabled == true then ball = display.newImageRect(sceneGroup,"upImages/ball/purple-white-ball.png",75,75) elseif user.isOrangeEnabled == true then ball = display.newImageRect(sceneGroup,"upImages/ball/orange-white-ball.png",75,75) elseif user.isBlueEnabled == true then ball = display.newImageRect(sceneGroup,"upImages/ball/blue-white-ball.png",75,75) elseif user.isGreenEnabled == true then ball = display.newImageRect(sceneGroup,"upImages/ball/green-white-ball.png",75,75) end ball.x = centerX ball.y = centerY ball.name = "ball" physics.addBody(ball,"dynamic",{radius = ballRadius, bounce = 0.4,filter = {category = 1, maskBits = 1 }}) ball.isFixedRotation = true
when ball collides with key, keys are removed but ball starts sliding
Collision is above which i posted earlier