How would i go about detecting a collision without physics?
Here is the code. Its a sample so you can put it into a portrait simulator and see what i want.
I want it so when the bullet gets to a wall it gets removed. This would be easy with physics but i dont want to use physics for this collision.
local physics = require("physics") physics.start() local centerX = display.contentCenterX local centerY = display.contentCenterY local actualW = display.actualContentWidth local actualH = display.actualContentHeight local bullet = {} local bCounter = 1 local bTimer local wallLeft = display.newRect( centerX - actualW/2 + 20, centerY, 10, actualH ) local wallRight = display.newRect( centerX + actualW/2 - 20, centerY, 10, actualH ) local wallTop = display.newRect( centerX, centerY - actualH/2 + 20, actualW, 10 ) local wallBottom = display.newRect( centerX, centerY + actualH/2 - 20, actualW, 10 ) local function shootBullet() local xB = math.random( -359, 359 ) local yB = math.random( -359, 359 ) bullet[bCounter] = display.newRect( centerX, centerY, 6, 6 ) bullet[bCounter].value = bCounter physics.addBody( bullet[bCounter], "dynamic", { isSensor = true } ) bullet[bCounter].gravityScale = 0 bullet[bCounter].myName = "bullet" bullet[bCounter]:setLinearVelocity( xB , yB ) bCounter = bCounter + 1 end bTimer = timer.performWithDelay( 100, shootBullet, -1 )
Thanks!
–SonicX278
