Copy link to clipboard
Copied
so I'm making a top-down shooter for fun, but have been struggling as I'm new to programming,
I have
var player: Player = new Player();
var Enemies: Array = new Array();
now I've been looking all over the net, but this is what I've been trying to work with.
public function checkCollisionWithShip(): void {
for (var e = Enemies.length - 1; e >= 0; e--) {
if (Enemies
trace(Enemies
Lives -= 1;
updateUI();
trace("ship collision!");
}
}
}
However, everytime my ship(player) touches an enemy, nothing ever happens.
looking forward to your replies,
thanks a lot for your time.
Unfortunately the code you are deciding needs to be shown is not the code that needs to be shown. What calls the function where the collision gets detected? I don't see anything for that.
Copy link to clipboard
Copied
What other code do you have for that class?
Copy link to clipboard
Copied
I have pasted the code you want to see, as I understand you wouldnt want to go through 400 lines
thank you for your help sir,
Copy link to clipboard
Copied
Unfortunately the code you are deciding needs to be shown is not the code that needs to be shown. What calls the function where the collision gets detected? I don't see anything for that.
Copy link to clipboard
Copied
oh my god, it took 9 days but now I understand why the code wasn't working.
What calls the function where the collision gets detected?
All this time I didn't have
checkCollisionWithShip();
inside my mainLoop();
Find more inspiration, events, and resources on the new Adobe Community
Explore Now