Hi everyone!,
I am having the same problem as a previous archived problem:
https://forums.coronalabs.com/topic/59614-bigger-touch-detection-area/
The only problem I am having is that the two awnsers that were given can’t be used in my example because:
-
I don’t use image’s for objects just display.newpolygon
-
I can’t use weld joints because my game doesn’t have physics.
I tried the following:
-- spawning function spawnShapes = function ( event ) local startX = mathRandom(50, w-50) local randomInt = mathRandom(difficultyTotal) print( randomInt ) local shape if(randomInt \<= (difficulty[1])) then shape = shapes[mathRandom(3)] elseif (randomInt \<= (difficulty[1]+difficulty[2])) then shape = shapes[4] else shape = shapes[5] end local color = colors[mathRandom(#colors)] local object if(shape == "circle") then object = display.newCircle( startX, -100, circleRad ) elseif(shape == "star") then --for beter touchable area object = display.newPolygon( startX, -100, vertices["star"] ) local touchObject = display.newRect( startX, -100, 100, 100 ) --object to be touched touchObject:setFillColor(0,0,0,1) touchObject.id = "star" touchObject.isHitTestable = true touchObject.connect = object object.connect = touchObject touchObject.touch = objectTouched transition.moveBy( touchObject, { y=h+300, time=difficulty[4], transition=easing.linear }) --move object down touchObject:addEventListener("touch", touchObject) sceneGroup:insert(touchObject) else object = display.newPolygon( startX, -100, vertices[shape] ) end object:setFillColor( colorsStat[color][1],colorsStat[color][2],colorsStat[color][3] ) object.enterFrame = offScreen object.touch = objectTouched object.strokeWidth = strokeThick object.stroke = strokeColors[color] object.id = shape Runtime:addEventListener( "enterFrame", object ) object:addEventListener( "touch", object ) transition.moveBy( object, { y=h+300, time=difficulty[4], transition=easing.linear }) --move object down sceneGroup:insert(object) end
I have touch object behind the first object but i don’t know how to delete it:
local function objectTouched(self, event) if (event.phase == "began") then --remove adjacent object if self.connect == not nil then --delete object print( "connected" ) Runtime:removeEventListener("enterFrame", self.connect) self.connect:removeSelf() end scoreLabel.text = score --delete object Runtime:removeEventListener("enterFrame", self) self:removeSelf() end end