Sorry, but i can’t find the error:
the text “win” dosen’t appears in the output
local W = display.contentWidth local H = display.contentHeight -- fisica local physics = require ("physics") physics.start() physics.setGravity(0, 5) physics.setScale(50) --oggetti display local circle = display.newCircle(367, 870, 50) physics.addBody(circle,"dinamic", {density = 1.0, friction = 0.3, bounce = 0.2}) local ground = display.newRect(0, 1280, 720, 1) physics.addBody(ground, "static", {}) local roof1 = display.newRect(0, 0, 180, 1) physics.addBody(roof1, "static", {}) local roof2 = display.newRect(540, 0, 180,1) physics.addBody(roof2, "static", {}) local wallS = display.newRect(0,0,1, 1280) physics.addBody(wallS, "static", {}) local wallD = display.newRect(720, 0, 1, 1280) physics.addBody(wallD, "static", {}) local bar1 = display.newRect(720/4,0, 15, 100) physics.addBody(bar1, "static", {}) local bar2 = display.newRect(540, 0, 15, 100) physics.addBody(bar2, "static", {}) local from\_x = bar1.x local from\_y = bar1.y local to\_x = bar2.x local to\_y = bar2.y local hits = physics.rayCast( from\_x, from\_y, to\_x, to\_y, "closest" ) if hits[1].object == circle then print ("You Win") end Runtime:addEventListener( "enterFrame", hits ) -- funzioni------------- --movimento palla function circleTouch(event) if event.phase == "began" then display.getCurrentStage():setFocus(circle) else if event.phase == "ended" then circle:applyLinearImpulse(event.xStart - event.x, event.yStart - event.y, circle.x, circle.y) display.getCurrentStage():setFocus(nil) end end end circle:addEventListener("touch", circleTouch) -- trascinamento ostacoli local function onTouch(self,e) if e.phase == "began" then display.getCurrentStage():setFocus( self ) self.isFocus = true self.tempJoint = physics.newJoint("touch", self, e.x,e.y) elseif e.phase == "moved" then self.tempJoint:setTarget(e.x, e.y) elseif e.phase == "ended" then self.tempJoint:removeSelf() display.getCurrentStage():setFocus( nil ) self.isFocus = false end return true end
