Hello! Im new to corona and lua, so excuse me if this a really stupid mistake.
I downloaded the Sticker Knight template and tried to make the knight shoot by adding in the following to the hero.lua file:
function instance:shoot(bx, by) local bullet = display.newImage("bullet.png", bx, by) bullet.type = "bullet" bullet.collision = bulletCollision bullet:addEventListener("collision", bullet) physics.addBody(bullet, "dynamic", { radius = 25, density = 1, friction = 5}) bullet:applyLinearImpulse(50, 0) local function bulletCollision(self, event) if event.target.type == "bullet" and event.other.type == "enemy" then print("ow") end end end
that function is then called when space is pressed and sets bx and by to the player position.
But the result is really weird.
When I shoot, I only get invisible collisions and the sprites are all out of place with the collisions. Its like it takes the display coordinates and the player position as different things.
Im really confused as to what I should do.