I have a problem . When I click on the gun it is suppose to fire straight out like it’s coming from the gun , but it doesn’t . It stutters behind the gun . When I click the gun the bullet is suppose to come from a certain place that makes it look like it’s coming from the gun .
minigun = display.newImage("minigun2.png") minigun.x = 50 minigun.y = 300 screenGroup:insert(minigun)
local bullet = {} local bCounter = 1 local function bulletMove(self, event) if self.x == -95 then display.remove( bullet ) else self.x = self.x - 2 end return true end local function gunTouched( event ) bullet = display.newImageRect( "bullet3.png", 50, 25 ) bullet.x = minigun.x - 40 bullet.y = minigun.y - 25 bullet.enterFrame = bulletMove Runtime:addEventListener( "enterFrame", bullet ) end function scene:show( event ) local sceneGroup = self.view local phase = event.phase if phase == "will" then elseif phase == "did" then end minigun:addEventListener( "touch", gunTouched ) end function scene:hide( event ) local sceneGroup = self.view local phase = event.phase if event.phase == "will" then Runtime:removeEventListener( "enterFrame", bullet ) elseif phase == "did" then end end function scene:destroy( event ) local sceneGroup = self.view if minigun then minigun:removeSelf( ) minigun = nil end end