Hello, you might have seen my other post about making a spin wheel, I have borrowed some code from another post by Rob Miracle. Whenever I try to run this, it just states that everything is a (nil value) error. Even adding a background is said to be an error. Could anyone please help me? I am trying to make my first app
local function gameLoop() angle = wheel.rotation if wheel.angularVelocity == 0 and angle ~= startingAngle then local wedge = math.floor(((angle + 45) % 360) /45) + 1 startingAngle = angle mydata.gameCategory = wedge if movementEnded then timer.performWithDelay(1000,playRound); end end end local function spinWheel(event) local t = event.target local phase = event.phase if (phase == "began") then display.getCurrentStage():setFocus( t ) t.isFocus = true t.x1 = event.x t.y1 = event.y startTime = event.time elseif t.isFocus then if (phase == "moved") then t.x2 = event.x t.y2 = event.y angle1 = 180/math.pi \* math.atan2(t.y1 - t.y , t.x1 - t.x) angle2 = 180/math.pi \* math.atan2(t.y2 - t.y , t.x2 - t.x) rotationAmt = angle1 - angle2 t.rotation = t.rotation - rotationAmt t.x1 = t.x2 t.y1 = t.y2 elseif (phase == "ended") or (phase == "cancelled") then local deltaTime = event.time - startTime if deltaTime \< 500 then wheel:applyAngularImpulse( 100000 + rand(33000)) wheel:removeEventListener("touch", spinWheel) else wheel:removeEventListener("touch", spinWheel) timer.performWithDelay(500,playRound); end movementEnded = true display.getCurrentStage():setFocus( nil ) t.isFocus = false end end return true end function scene:createScene( event ) local group = self.view physics.start() physics.setGravity(0,0) physics.pause() local background = display.newImageRect("snipwheel3.jpg", 756, 504) background.x = display.contentWidth / 2 background.y = display.contentHeight / 2 group:insert(background) wheel = display.newImageRect("images/wheel.png", 250, 250) startingAngle = wheel.rotation print("Starting Angle: " .. startingAngle) wheel.x = 140 wheel.y = display.contentHeight / 2 + 20 group:insert(wheel) physics.addBody(wheel, {density=0.5, friction=0.8, bounce=0.0, radius=125 } ) wheel.angularDamping = 0.7 wheel:addEventListener("touch", spinWheel) local pointer = display.newImageRect("images/pointer.png", 32, 16) pointer.x = 15 pointer.y = display.contentHeight / 2 + 20 group:insert(pointer) end function scene:enterScene( event ) local group = self.view storyboard.removeScene("loading") Runtime:addEventListener("enterFrame", gameLoop) physics.start() end