Hey! I have another question. With this code. How would i go about detecting a 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 i = 1 local wallLeft = display.newRect( centerX - actualW/2 + 20, centerY, 10, actualH ) wallLeft.myName = "wallLeft" 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 bob() if #bullet \>= 1 then print("hi") end return true end local function shootBullet(event) 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( -100 , 0 ) bCounter = bCounter + 1 end bTimer = timer.performWithDelay( 100, shootBullet, 1 ) Runtime:addEventListener( "enterFrame", bob )
–SonicX278
