Hello! I was making a “Space Invaders” game. I was making the code tween all the invaders downwards when I ran into an error. I don’t understand what the problem is. Please help.
Here’s the code that I use for lowering the invaders:
function lowerInvaders()
for i,a in ipairs(invaders) do
tween(0.5,a,{position.y = a.position.y - 20}) -- Error: "}" expected near "="
end
end
Alright, so now I’m moving on to making the player’s ship. So I made a bullet class, and each bulllet has a static physics body for their hitbox. The invaders also have static physics bodies for their hitboxes. I’m trying to make it so that if a bullet hits an invader, both the invader and the bullet will be destroyed, and removed from their table (bullets and invaders are the two tables). Not sure how to do that though.
function collide(contact)
if contact.state == BEGAN then
if contact.bodyA == "invader" and contact.bodyB == "bullet" or contact.bodyB == "invader" and contact.bodyA == "bullet" then
end
end
end
I wrote this, to detect the collisions, but I don’t know what to write next.
@Kolosso - it seems to me that you’re learning how to make your game by asking questions each time you get stuck, and while we don’t mind helping fix problems, we’d like you to try to find answers in the many tutorials, sample code, ebooks etc available to you, because we don’t have time to provide one to one tuition.
For example (and this is only one resource), I’ve written an ebook on Codea, which covers physics and collisions, at this link.
So please take the time and trouble to do some reading before asking questions.